Skip to content

Commit

Permalink
reverting onUpdatView event / added blocks to index view template
Browse files Browse the repository at this point in the history
  • Loading branch information
nateiler committed Jun 5, 2019
1 parent b7a6d73 commit 706c226
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 38 deletions.
64 changes: 34 additions & 30 deletions src/templates/_elements/index.twig
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
{% set sources = sources ?? craft.app.elementIndexes.getSources(elementType, 'index') %}
{% set customizableSources = customizableSources ?? false %}
{% set addButton = addButton is defined ? addButton : '<div class="btn add icon"></div>' %}
{% if element.id %}
<div id="{{ container }}">
<div class="elementindex">
{% include 'nested-element-index/_elements/indexcontainer' with {
elementType: elementType,
sources: sources,
customizableSources: customizableSources,
addButton: addButton,
sortOptions: sortOptions ?? null
} only %}
{% block container %}
{% if element.id %}
<div id="{{ container }}">
<div class="elementindex">
{% include 'nested-element-index/_elements/indexcontainer' with {
elementType: elementType,
sources: sources,
customizableSources: customizableSources,
addButton: addButton,
sortOptions: sortOptions ?? null
} only %}
</div>
</div>
</div>

{% else %}
<p><i>{{ "Please save element before making any associations."|t('element-list') }}</i></p>
{% endif %}
{% else %}
<p><i>{{ "Please save element before making any associations."|t('element-list') }}</i></p>
{% endif %}
{% endblock %}

{% set inputVar = ('input-'~container)|namespaceInputId|replace({'-': '_'}) %}
{% set indexVar = ('index-'~container)|namespaceInputId|replace({'-': '_'}) %}
{% js %}
var {{ inputVar }} = new {{ inputJsClass }}($('#{{ container|namespaceInputId }}'), {{ inputJs|json_encode|raw }});
{% block js %}
{% set inputVar = ('input-'~container)|namespaceInputId|replace({'-': '_'}) %}
{% set indexVar = ('index-'~container)|namespaceInputId|replace({'-': '_'}) %}
{% js %}
var {{ inputVar }} = new {{ inputJsClass }}($('#{{ container|namespaceInputId }}'), {{ inputJs|json_encode|raw }});

var {{ indexVar }} = new {{ indexJsClass }}(
'{{ elementType|e("js") }}',
$('#{{ container|namespaceInputId }}'),
{{ indexJs|json_encode|raw }}
);
var {{ indexVar }} = new {{ indexJsClass }}(
'{{ elementType|e("js") }}',
$('#{{ container|namespaceInputId }}'),
{{ indexJs|json_encode|raw }}
);

{{ indexVar }}.on('afterAction', function(data) {
{{ inputVar }}.removeElements(data.params.elementIds);
});
{{ indexVar }}.on('afterAction', function(data) {
{{ inputVar }}.removeElements(data.params.elementIds);
});

{{ inputVar }}.on('selectElements', function(data) {
{{ indexVar }}.updateElements();
});
{% endjs %}
{{ inputVar }}.on('selectElements', function(data) {
{{ indexVar }}.updateElements();
});
{% endjs %}
{% endblock %}
8 changes: 1 addition & 7 deletions src/web/assets/index/dist/js/NestedElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ Craft.NestedElementIndex = Craft.BaseElementIndex.extend({
return this.base(mode, $.extend(settings, this.settings.viewSettings));
},

_updateView: function(params, response) {
this.base(params, response);
this.settings.onUpdateView(response.html);
},

// UI state handlers
// -------------------------------------------------------------------------

Expand All @@ -34,7 +29,6 @@ Craft.NestedElementIndex = Craft.BaseElementIndex.extend({
}, {
defaults: {
viewParams: {},
viewSettings: {},
onUpdateView: $.noop,
viewSettings: {}
}
});
2 changes: 1 addition & 1 deletion src/web/assets/index/dist/js/NestedElementIndex.min.js

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

0 comments on commit 706c226

Please sign in to comment.