mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/6466] Support form reset and do not loose role upon resubmit
PHPBB3-6466
This commit is contained in:
parent
2e46bef2ec
commit
44b8dafb23
3 changed files with 31 additions and 5 deletions
|
@ -50,7 +50,7 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<input type="hidden" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]" />
|
||||
<input type="hidden" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]"{% if S_ROLE_ID %}value="{{ S_ROLE_ID }}"{% endif %} />
|
||||
</div>
|
||||
</dd>
|
||||
{% else %}
|
||||
|
|
|
@ -141,15 +141,20 @@ phpbb.positionTooltip = function ($element) {
|
|||
*/
|
||||
phpbb.prepareRolesDropdown = function () {
|
||||
var $options = $('.roles-options li');
|
||||
var $rolesOptions = $options.closest('.roles-options');
|
||||
var $span = $rolesOptions.children('span');
|
||||
|
||||
// Prepare highlighting of select options and settings update
|
||||
$options.each(function () {
|
||||
var $this = $(this);
|
||||
var $rolesOptions = $this.closest('.roles-options');
|
||||
|
||||
// Correctly show selected option
|
||||
if (typeof $this.attr('data-selected') !== 'undefined') {
|
||||
$this.closest('.roles-options').children('span').text($this.text());
|
||||
$rolesOptions.closest('.roles-options')
|
||||
.children('span')
|
||||
.text($this.text())
|
||||
.attr('data-default', $this.text())
|
||||
.attr('data-default-val', $this.attr('data-id'));
|
||||
}
|
||||
|
||||
$this.on('mouseover', function () {
|
||||
|
@ -164,13 +169,28 @@ phpbb.prepareRolesDropdown = function () {
|
|||
init_colours($this.attr('data-target-id').replace('advanced', ''));
|
||||
|
||||
// Set selected setting
|
||||
$rolesOptions.children('span').text($this.text());
|
||||
$rolesOptions.children('input[type=hidden]').val($this.attr('data-id'));
|
||||
$rolesOptions.children('span')
|
||||
.text($this.text());
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($this.attr('data-id'));
|
||||
|
||||
// Trigger hiding of selection options
|
||||
$('body').trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
// Save default text of drop down if there is no default set yet
|
||||
if (typeof $span.attr('data-default') === 'undefined') {
|
||||
$span.attr('data-default', $span.text());
|
||||
}
|
||||
|
||||
// Prepare resetting drop down on form reset
|
||||
$options.closest('form').on('reset', function () {
|
||||
$span.text($span.attr('data-default'));
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($span.attr('data-id'));
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Run onload functions for RolesDropdown and tooltips
|
||||
|
|
|
@ -470,6 +470,9 @@ class auth_admin extends \phpbb\auth\auth
|
|||
// Build role dropdown options
|
||||
$current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0;
|
||||
|
||||
// Output current role id to template
|
||||
$template->assign_var('S_ROLE_ID', $current_role_id);
|
||||
|
||||
@reset($roles);
|
||||
while (list($role_id, $role_row) = each($roles))
|
||||
{
|
||||
|
@ -552,6 +555,9 @@ class auth_admin extends \phpbb\auth\auth
|
|||
// Build role dropdown options
|
||||
$current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0;
|
||||
|
||||
// Output current role id to template
|
||||
$template->assign_var('S_ROLE_ID', $current_role_id);
|
||||
|
||||
@reset($roles);
|
||||
while (list($role_id, $role_row) = each($roles))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue