1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/6466] Support form reset and do not loose role upon resubmit

PHPBB3-6466
This commit is contained in:
Marc Alexander
2015-05-30 11:20:04 +02:00
parent 2e46bef2ec
commit 44b8dafb23
3 changed files with 31 additions and 5 deletions

View File

@@ -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 %}

View File

@@ -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