Skip to content

Commit

Permalink
Merge branch 'wip-MDL-16855-master' of https://github.com/marinaglanc…
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Apr 13, 2016
2 parents 27bfb0e + 1e34257 commit 1013030
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 25 deletions.
2 changes: 2 additions & 0 deletions lang/en/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
$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';
Expand All @@ -96,6 +97,7 @@
$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.';
Expand Down
2 changes: 1 addition & 1 deletion lib/amd/build/tag.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions lib/amd/src/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
},

/**
Expand Down
6 changes: 4 additions & 2 deletions mod/wiki/tests/behat/edit_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 18 additions & 4 deletions tag/classes/manage_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function __construct($tagcollid) {

$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'),
Expand Down Expand Up @@ -88,9 +89,9 @@ public function __construct($tagcollid) {
$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);
Expand All @@ -103,6 +104,19 @@ public function __construct($tagcollid) {

}

/**
* @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.
*
Expand Down
Loading

0 comments on commit 1013030

Please sign in to comment.