Browse Source

Remove links for editing/deleting related objects from RelatedMultipleWidgetWrapper.

Adding HTML markup into each option requires disabling HTML escaping on
the option, which means the option name is also not escaped. While this
is not a very high risk, these extra links add marginal extra utility
and require a fair bit of Javascript, so it seems to be better just to
remove them.
master
Samir Shah 3 years ago
parent
commit
59448c826f

+ 0
- 26
src/oscar/static_src/oscar/js/oscar/dashboard.js View File

166
                 width: 'resolve'
166
                 width: 'resolve'
167
             });
167
             });
168
             $selects.filter('.related-widget-wrapper.multiple select').select2({
168
             $selects.filter('.related-widget-wrapper.multiple select').select2({
169
-                templateResult: function (data) {
170
-                    return $(data.element).text();
171
-                },
172
-                templateSelection: function (data) {
173
-                    var $this = $(data.element).closest('.related-widget-wrapper');
174
-                    var siblings = $this.find('.change-related, .delete-related');
175
-                    if (!siblings.length) {
176
-                        return;
177
-                    }
178
-                    var value = data.id;
179
-                    var label = $(data.element).text();
180
-                    if (value) {
181
-                        siblings.each(function() {
182
-                            var elm = $(this);
183
-                            elm.attr('href', elm.attr('data-href-template').replace('__fk__', value));
184
-                            label += ' ';
185
-                            label += elm[0].outerHTML;
186
-                        });
187
-                    } else {
188
-                        siblings.removeAttr('href');
189
-                    }
190
-                    return label;
191
-                },
192
-                escapeMarkup: function(markup) {
193
-                    return markup;
194
-                },
195
                 width: '95%'
169
                 width: '95%'
196
             });
170
             });
197
             $(el).find('select.select2').each(function(i, e) {
171
             $(el).find('select.select2').each(function(i, e) {

+ 0
- 12
src/oscar/templates/oscar/dashboard/widgets/related_multiple_widget_wrapper.html View File

3
     {{ rendered_widget }}
3
     {{ rendered_widget }}
4
     {% block links %}
4
     {% block links %}
5
         {% spaceless %}
5
         {% spaceless %}
6
-        <div class="d-none">
7
-            <a class="related-widget-wrapper-link change-related" id="change_id_{{ name }}"
8
-                data-href-template="{{ change_related_template_url }}?{{ url_params }}"
9
-                title="{% blocktrans %}Change selected {{ model }}{% endblocktrans %}">
10
-                <i class="fas fa-pencil-alt"></i>
11
-            </a>
12
-            <a class="related-widget-wrapper-link delete-related" id="delete_id_{{ name }}"
13
-                data-href-template="{{ delete_related_template_url }}?{{ url_params }}"
14
-                title="{% blocktrans %}Delete selected {{ model }}{% endblocktrans %}">
15
-                <i class="fas fa-trash-alt"></i>
16
-            </a>
17
-        </div>
18
         <a class="related-widget-wrapper-link add-related" id="create_id_{{ name }}"
6
         <a class="related-widget-wrapper-link add-related" id="create_id_{{ name }}"
19
             href="{{ add_related_url }}?{{ url_params }}"
7
             href="{{ add_related_url }}?{{ url_params }}"
20
             title="{% blocktrans %}Add another {{ model }}{% endblocktrans %}">
8
             title="{% blocktrans %}Add another {{ model }}{% endblocktrans %}">

Loading…
Cancel
Save