|
1 | | -@extends('menu_architect::master') |
| 1 | +@extends('menu_architect::page') |
2 | 2 |
|
3 | 3 | @section('title', 'Edit Menu') |
4 | 4 |
|
5 | | -@section('content') |
| 5 | +@section('content_header') |
6 | 6 | <h1 class="page-title"> |
7 | 7 | <i class="glyphicon glyphicon-list"></i> Menu Item ({{ $model->data->name }}) |
8 | 8 | </h1> |
| 9 | +@stop |
| 10 | + |
| 11 | +@section('content') |
9 | 12 | <div class="alert alert-info"> |
10 | 13 | <strong>How To Use:</strong> |
11 | 14 | <p> |
12 | | - You can output a menu html anywhere on your site by calling <code>menu_arct('{{ $model->data->name }}')</code>, <a target="_blank" href="{{route('menu_arct.example')}}">see more examples.</a> |
| 15 | + You can output a menu html anywhere on your site by calling <code>menu_arct('{{ $model->data->name }}')</code>.</a> |
13 | 16 | </p> |
14 | 17 | </div> |
15 | 18 |
|
|
29 | 32 | @enderror |
30 | 33 | </div> |
31 | 34 | </div> |
| 35 | + <div class="text-right"> |
| 36 | + <a href="{{ route('menu_arct.index') }}" class="btn btn-default">Cancel</a> |
| 37 | + <button type="submit" class="btn btn-primary">Submit</button> |
| 38 | + </div> |
32 | 39 | </div> |
33 | 40 | </div> |
34 | | - <div class="text-right"> |
35 | | - <a href="{{ route('menu_arct.index') }}" class="btn btn-default">Cancel</a> |
36 | | - <button type="submit" class="btn btn-primary">Submit</button> |
37 | | - </div> |
38 | 41 | </form> |
39 | 42 |
|
40 | | -<div class="box box-solid"> |
| 43 | +<div class="box box-solid marct-builder"> |
41 | 44 | <div class="box-header with-border"> |
42 | 45 | <h3 class="box-title">Menu Builder |
43 | | - <button type="button" class="btn btn-success create" data-toggle="modal" data-target="#addItemModal"> |
| 46 | + <button type="button" class="btn btn-success marct-create" data-target="#addItemModal"> |
44 | 47 | <i class="glyphicon glyphicon-plus"></i> Add New Item |
45 | 48 | </button> |
46 | 49 | </h3> |
|
58 | 61 | </div> |
59 | 62 | </div> |
60 | 63 |
|
61 | | -@include('menu_architect::menu_item.create', compact('model')) |
62 | | -@include('menu_architect::menu_item.edit', compact('model')) |
| 64 | +@include('menu_architect::menu._item_create', compact('model')) |
| 65 | +@include('menu_architect::menu._item_edit', compact('model')) |
63 | 66 |
|
64 | 67 | @endsection |
65 | 68 |
|
|
94 | 97 | }, |
95 | 98 | toolRenderer: function (item_attrs_string, item) { |
96 | 99 | var html = '<div class="pull-right item_actions">'; |
97 | | - html += '<a href="' + opt.updateUrl.replace('replace_id', item.id) + '" class="btn btn-primary edit"' + item_attrs_string + '>'; |
| 100 | + html += '<a href="' + opt.updateUrl.replace('replace_id', item.id) + '" class="btn btn-primary marct-edit"' + item_attrs_string + '>'; |
98 | 101 | html += '<i class="glyphicon glyphicon-edit"></i> Edit'; |
99 | 102 | html += '</a>'; |
100 | | - html += '<a href="' + opt.destroyUrl.replace('replace_id', item.id) + '" data-rel="btnConfirm" data-timeout="2" data-confirm-text="Double touch to remove!" class="btn btn-danger delete"' + item_attrs_string + '>'; |
| 103 | + html += '<a href="' + opt.destroyUrl.replace('replace_id', item.id) + '" data-rel="btnConfirm" data-timeout="2" data-confirm-text="Double touch to remove!" class="btn btn-danger marct-delete"' + item_attrs_string + '>'; |
101 | 104 | html += '<i class="glyphicon glyphicon-trash"></i> Delete'; |
102 | 105 | html += '</a>'; |
103 | 106 | html += '</div>'; |
|
137 | 140 | children = item.children(nestable.options.listNodeName).children(nestable.options.itemNodeName); |
138 | 141 | item.after(children); |
139 | 142 | nestable.remove(data.id); |
| 143 | + Toast.fire({ |
| 144 | + icon: 'success', |
| 145 | + title: 'remove success ' + data.label |
| 146 | + }) |
140 | 147 | }) |
141 | 148 | .on('ajax:beforeSend', '[data-rel="btnConfirm"]', function (event, xhr, settings) { /* */ }) |
142 | 149 | .on('ajax:error', '[data-rel="btnConfirm"]', function (event, xhr, status, error) { /* */ }) |
143 | | - .on('ajax:complete', '[data-rel="btnConfirm"]', function (event, xhr, status) { /* */ }) |
144 | | - .on('click', '.edit', function (event) { |
| 150 | + .on('ajax:complete', '[data-rel="btnConfirm"]', function (event, xhr, status) { /* */ }); |
| 151 | +
|
| 152 | + $('.marct-builder') |
| 153 | + .on('click', '.marct-create', function (event) { |
| 154 | + event.preventDefault(); |
| 155 | + $('#addItemModal').modal('show', this); |
| 156 | + }) |
| 157 | + .on('click', '.marct-edit', function (event) { |
145 | 158 | event.preventDefault(); |
146 | 159 | $('#editItemModal').modal('show', this); |
147 | 160 | }); |
148 | 161 |
|
149 | | - const Toast = Swal.mixin({ |
150 | | - toast: true, |
151 | | - position: 'top-end', |
152 | | - showConfirmButton: false, |
153 | | - timer: 3000, |
154 | | - timerProgressBar: true, |
155 | | - onOpen: (toast) => { |
156 | | - toast.addEventListener('mouseenter', Swal.stopTimer) |
157 | | - toast.addEventListener('mouseleave', Swal.resumeTimer) |
158 | | - } |
159 | | - }) |
| 162 | + const Toast = Swal.mixin({ |
| 163 | + toast: true, |
| 164 | + position: 'top-end', |
| 165 | + showConfirmButton: false, |
| 166 | + timer: 3000, |
| 167 | + timerProgressBar: true, |
| 168 | + onOpen: (toast) => { |
| 169 | + toast.addEventListener('mouseenter', Swal.stopTimer) |
| 170 | + toast.addEventListener('mouseleave', Swal.resumeTimer) |
| 171 | + } |
| 172 | + }) |
160 | 173 |
|
161 | 174 | $('.modal[role="dialog"]') |
162 | 175 | .on('shown.bs.modal', function (event) { |
|
168 | 181 | modal.find('form').each(function () |
169 | 182 | { |
170 | 183 | this.reset(); |
171 | | - if(action) |
| 184 | + if(action) { |
172 | 185 | $(this).attr('action', action); |
173 | | - for(var key in recipient) { |
174 | | - $('[name="' + key + '"]').val(recipient[key]).trigger('change'); |
| 186 | + for(var key in recipient) { |
| 187 | + $('[name="' + key + '"]').val(recipient[key]).trigger('change'); |
| 188 | + } |
175 | 189 | } |
176 | 190 | }); |
177 | 191 | }) |
178 | | - .on('click', '.submit', function (event) { |
| 192 | + .on('click', '.marct-submit', function (event) { |
179 | 193 | $(event.delegateTarget).modal('hide'); |
180 | 194 | $form = $(event.delegateTarget).find('form'); |
181 | 195 | $.ajax({ |
|
185 | 199 | }).done(function(data, status, xhr) { |
186 | 200 | let nestable = $nestable.data('nestable'), |
187 | 201 | item = nestable._getItemById(data.properties.id); |
| 202 | + if(data.properties.parent_id == 0) |
| 203 | + delete data.properties.parent_id; |
188 | 204 | if(item.length > 0) |
189 | 205 | nestable.replace(data.properties); |
190 | 206 | else |
|
0 commit comments