Add button lacks loading state - Refs #2772

This commit is contained in:
Samuel Georges 2017-04-24 12:32:08 +10:00
parent 0fa0301557
commit acfe619cb9
2 changed files with 20 additions and 11 deletions

View File

@ -171,12 +171,14 @@ class Repeater extends FormWidgetBase
*/
protected function processExistingItems()
{
$loadValue = $this->getLoadValue();
$loadedIndexes = $loadedGroups = [];
foreach ($loadValue as $loadedValue) {
$loadedIndexes[] = array_get($loadedValue, '_index');
$loadedGroups[] = array_get($loadedValue, '_group');
$loadValue = $this->getLoadValue();
if (is_array($loadValue)) {
foreach ($loadValue as $loadedValue) {
$loadedIndexes[] = array_get($loadedValue, '_index');
$loadedGroups[] = array_get($loadedValue, '_group');
}
}
$itemIndexes = post($this->indexInputName, $loadedIndexes);

View File

@ -85,7 +85,8 @@
Repeater.prototype.clickAddGroupButton = function(ev) {
var templateHtml = $('> [data-group-palette-template]', this.$el).html(),
$target = $(ev.target),
$form = this.$el.closest('form')
$form = this.$el.closest('form'),
$loadContainer = $target.closest('.loading-indicator-container')
$target.ocPopover({
content: templateHtml
@ -93,11 +94,17 @@
var $container = $target.data('oc.popover').$container
$container.on('click', 'a', function (ev) {
setTimeout(function() {
$(ev.target).trigger('close.oc.popover')
}, 1)
})
$container
.on('click', 'a', function (ev) {
setTimeout(function() { $(ev.target).trigger('close.oc.popover') }, 1)
})
.on('ajaxPromise', '[data-repeater-add]', function(ev, context) {
$loadContainer.loadIndicator()
$form.one('ajaxComplete', function() {
$loadContainer.loadIndicator('hide')
})
})
$('[data-repeater-add]', $container).data('request-form', $form)
}