Commit 10130303 authored by David Monllaó's avatar David Monllaó
Browse files

Merge branch 'wip-MDL-16855-master' of https://github.com/marinaglancy/moodle

parents 27bfb0ee 1e34257e
......@@ -74,6 +74,7 @@ $string['combined'] = 'Tags are combined';
$string['combineselected'] = 'Combine selected';
$string['id'] = 'id';
$string['inalltagcoll'] = 'Everywhere';
$string['inputstandardtags'] = 'Enter comma-separated list of new tags';
$string['itemstaggedwith'] = '{$a->tagarea} tagged with "{$a->tag}"';
$string['lesstags'] = 'less...';
$string['managestandardtags'] = 'Manage standard tags';
......@@ -96,6 +97,7 @@ $string['relatedblogs'] = 'Most recent blog entries';
$string['relatedtags'] = 'Related tags';
$string['removetagfrommyinterests'] = 'Remove "{$a}" from my interests';
$string['reset'] = 'Tag flag reset';
$string['resetfilter'] = 'Reset filter';
$string['resetflag'] = 'Reset flag';
$string['responsiblewillbenotified'] = 'The person responsible will be notified';
$string['rssdesc'] = 'This RSS feed was automatically generated by Moodle and contains user generated tags for courses.';
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -196,6 +196,41 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
});
}
});
// Form for adding standard tags.
$('body').on('click', 'a[data-action=addstandardtag]', function(e) {
e.preventDefault();
str.get_strings([
{key : 'addotags', component : 'tag'},
{key : 'inputstandardtags', component : 'tag'},
{key : 'continue'},
{key : 'cancel'},
]).done(function(s) {
var el = $('<div><form id="addtags_form" class="form-inline" method="POST">' +
'<input type="hidden" name="action" value="addstandardtag"/>' +
'<input type="hidden" name="sesskey" value="' + M.cfg.sesskey + '"/>' +
'<p><label for="id_tagslist">' + s[1] + '</label>' +
'<input type="text" id="id_tagslist" name="tagslist"/></p>' +
'<p class="mdl-align"><input type="submit" id="addtags_submit"/>' +
'<input type="button" id="addtags_cancel"/></p>' +
'</form></div>');
el.find('#addtags_form').attr('action', window.location.href);
el.find('#addtags_submit').attr('value', s[2]);
el.find('#addtags_cancel').attr('value', s[3]);
var panel = new M.core.dialogue ({
draggable: true,
modal: true,
closeButton: true,
headerContent: s[0],
bodyContent: el.html()
});
panel.show();
$('#addtags_form input[type=text]').focus();
$('#addtags_form #addtags_cancel').on('click', function() {
panel.destroy();
});
});
});
},
/**
......
......@@ -44,14 +44,16 @@ Feature: Edited wiki pages handle tags correctly
Then I should see "Cool" in the ".form-autocomplete-selection" "css_element"
And I press "Cancel"
@javascript
Scenario: Wiki page edition of standard tags works as expected
Given I log in as "admin"
And I expand "Site administration" node
And I expand "Appearance" node
And I follow "Manage tags"
And I follow "Default collection"
And I set the field "otagsadd" to "OT1, OT2, OT3"
And I press "Add standard tags"
And I follow "Add standard tags"
And I set the field "Enter comma-separated list of new tags" to "OT1, OT2, OT3"
And I press "Continue"
And I log out
And I log in as "student1"
And I follow "Course 1"
......
......@@ -54,8 +54,9 @@ class core_tag_manage_table extends table_sql {
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$filter = optional_param('filter', '', PARAM_NOTAGS);
$baseurl = new moodle_url('/tag/manage.php', array('tc' => $tagcollid,
'perpage' => $perpage, 'page' => $page));
'perpage' => $perpage, 'page' => $page, 'filter' => $filter));
$tablecolumns = array('select', 'name', 'fullname', 'count', 'flag', 'timemodified', 'isstandard', 'controls');
$tableheaders = array(get_string('select', 'tag'),
......@@ -88,9 +89,9 @@ class core_tag_manage_table extends table_sql {
$this->set_attribute('id', 'tag-management-list');
$this->set_attribute('class', 'admintable generaltable tag-management-table');
$totalcount = "SELECT COUNT(id)
FROM {tag}
WHERE tagcollid = :tagcollid";
$totalcount = "SELECT COUNT(tg.id)
FROM {tag} tg
WHERE tg.tagcollid = :tagcollid";
$params = array('tagcollid' => $this->tagcollid);
$this->set_count_sql($totalcount, $params);
......@@ -103,6 +104,19 @@ class core_tag_manage_table extends table_sql {
}
/**
* @return string sql to add to where statement.
*/
function get_sql_where() {
$filter = optional_param('filter', '', PARAM_NOTAGS);
list($wsql, $wparams) = parent::get_sql_where();
if ($filter !== '') {
$wsql .= ($wsql ? ' AND ' : '') . 'tg.name LIKE :tagfilter';
$wparams['tagfilter'] = '%' . $filter . '%';
}
return array($wsql, $wparams);
}
/**
* Query the db. Store results in the table object for use by build_table.
*
......
......@@ -38,6 +38,7 @@ $perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$tagcollid = optional_param('tc', 0, PARAM_INT);
$tagareaid = optional_param('ta', null, PARAM_INT);
$filter = optional_param('filter', '', PARAM_NOTAGS);
$params = array();
if ($perpage != DEFAULT_PAGE_SIZE) {
......@@ -49,6 +50,9 @@ if ($page > 0) {
if ($tagcollid) {
$params['tc'] = $tagcollid;
}
if ($filter !== '') {
$params['filter'] = $filter;
}
admin_externalpage_setup('managetags', '', $params, '', array('pagelayout' => 'report'));
......@@ -163,8 +167,8 @@ switch($action) {
require_sesskey();
$tagobjects = array();
if ($tagcoll) {
$otagsadd = optional_param('otagsadd', '', PARAM_RAW);
$newtags = preg_split('/\s*,\s*/', trim($otagsadd), -1, PREG_SPLIT_NO_EMPTY);
$tagslist = optional_param('tagslist', '', PARAM_RAW);
$newtags = preg_split('/\s*,\s*/', trim($tagslist), -1, PREG_SPLIT_NO_EMPTY);
$tagobjects = core_tag_tag::create_if_missing($tagcoll->id, $newtags, true);
}
foreach ($tagobjects as $tagobject) {
......@@ -202,21 +206,24 @@ if (!$tagcoll) {
// Tag collection is specified. Manage tags in this collection.
echo $OUTPUT->heading(core_tag_collection::display_name($tagcoll));
// Small form to add an standard tag.
print('<form class="tag-addtags-form" method="post" action="'.$CFG->wwwroot.'/tag/manage.php">');
print('<input type="hidden" name="tc" value="'.$tagcollid.'" />');
print('<input type="hidden" name="action" value="addstandardtag" />');
print('<input type="hidden" name="perpage" value="'.$perpage.'" />');
print('<input type="hidden" name="page" value="'.$page.'" />');
print('<div class="tag-management-form generalbox"><label class="accesshide" for="id_otagsadd">' .
get_string('addotags', 'tag') .'</label>'.
'<input name="otagsadd" id="id_otagsadd" type="text" />'.
'<input type="hidden" name="sesskey" value="'.sesskey().'">'.
'<input name="addotags" value="'. get_string('addotags', 'tag') .
'" onclick="skipClientValidation = true;" id="id_addotags" type="submit" />'.
// Form to filter tags.
print('<form class="tag-filter-form" method="get" action="'.$CFG->wwwroot.'/tag/manage.php">');
print('<div class="tag-management-form generalbox"><label class="accesshide" for="id_tagfilter">'. get_string('search') .'</label>'.
'<input type="hidden" name="tc" value="'.$tagcollid.'" />'.
'<input type="hidden" name="perpage" value="'.$perpage.'" />'.
'<input id="id_tagfilter" name="filter" type="text" value=' . s($filter) . '>'.
'<input value="'. s(get_string('search')) .'" type="submit"> '.
($filter !== '' ? html_writer::link(new moodle_url($PAGE->url, array('filter' => null)),
get_string('resetfilter', 'tag'), array('class' => 'resetfilterlink')) : '').
'</div>');
print('</form>');
// Link to add an standard tags.
$img = $OUTPUT->pix_icon('t/add', '');
echo '<div class="addstandardtags visibleifjs">' .
html_writer::link('#', $img . get_string('addotags', 'tag'), array('data-action' => 'addstandardtag')) .
'</div>';
$table = new core_tag_manage_table($tagcollid);
echo '<form class="tag-management-form" method="post" action="'.$CFG->wwwroot.'/tag/manage.php">';
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'tc', 'value' => $tagcollid));
......
......@@ -219,3 +219,20 @@ Feature: Users can edit tags to add description or rename
# Even though Turtle was not standard but at least one of combined tags was (Neverusedtag). Now Turtle is also standard.
And "Remove from standard tags" "link" should exist in the "Turtle" "table_row"
And I log out
Scenario: Filtering tags
When I log in as "manager1"
And I navigate to "Manage tags" node in "Site administration > Appearance"
And I follow "Default collection"
And I should not see "Reset filter"
And I set the field "Search" to "t"
And I press "Search"
Then the field "Search" matches value "t"
And I should not see "Dog"
And I should see "Cat"
And I should see "Turtle"
And I follow "Reset filter"
And I should see "Dog"
And I should see "Cat"
And I should see "Turtle"
And I log out
......@@ -19,6 +19,7 @@ Feature: Manager can add standard tags and change the tag type of existing tags
| Tag2 | 0 |
| Tag3 | 1 |
@javascript
Scenario: Adding standard tags
When I log in as "manager1"
And I navigate to "Manage tags" node in "Site administration > Appearance"
......@@ -27,9 +28,9 @@ Feature: Manager can add standard tags and change the tag type of existing tags
And "Make standard" "link" should exist in the "Tag1" "table_row"
And "Make standard" "link" should exist in the "Tag2" "table_row"
And "Remove from standard tags" "link" should exist in the "Tag3" "table_row"
And I set the following fields to these values:
| Add standard tags | Tag1,TAG2,Tag3,Tag4,Tag5 |
And I press "Add standard tags"
And I follow "Add standard tags"
And I set the field "Enter comma-separated list of new tags" to "Tag1,TAG2,Tag3,Tag4,Tag5"
And I press "Continue"
And I should see "Standard tag(s) added"
# No changes to Tag0
And "Make standard" "link" should exist in the "Tag0" "table_row"
......
......@@ -829,6 +829,15 @@ tr.flagged-tag a {
.tag-management-table .inplaceeditable.inplaceeditingon input {
width: 150px;
}
.path-admin-tag .addstandardtags {
float: right;
img {
margin: 0 5px;
}
}
.dir-rtl.path-admin-tag .addstandardtags {
float: left;
}
.path-tag .tag-relatedtags {
padding-top: 10px;
}
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment