Skip to content

Commit 1318645

Browse files
committed
Refactoring view stracture; comprehensive mvc;
1 parent 29c2d1b commit 1318645

File tree

12 files changed

+102
-136
lines changed

12 files changed

+102
-136
lines changed

resources/views/master.blade.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@
77
<meta name="csrf-token" content="{{ csrf_token() }}">
88
<title>@yield('title')</title>
99

10-
@include('menu_architect::plugins', ['type' => 'css'])
10+
@stack('css')
1111
@yield('css')
1212
</head>
1313
<body>
14+
1415
<div class="container-fluid">
16+
17+
<section class="content-header">
18+
@yield('content_header')
19+
</section>
20+
1521
@yield('content')
1622
</div>
1723

18-
@include('menu_architect::plugins', ['type' => 'js'])
24+
@stack('js')
1925
@yield('js')
2026
</body>
2127
</html>

resources/views/menu_item/create.blade.php renamed to resources/views/menu/_item_create.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</div>
5454
<div class="modal-footer">
5555
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
56-
<button type="button" class="btn btn-primary submit">Submit</button>
56+
<button type="button" class="btn btn-primary marct-submit">Submit</button>
5757
</div>
5858
</div>
5959
</div>

resources/views/menu_item/edit.blade.php renamed to resources/views/menu/_item_edit.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</div>
5555
<div class="modal-footer">
5656
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
57-
<button type="button" class="btn btn-primary submit">Submit</button>
57+
<button type="button" class="btn btn-primary marct-submit">Submit</button>
5858
</div>
5959
</div>
6060
</div>

resources/views/menu/create.blade.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
@extends('menu_architect::master')
1+
@extends('menu_architect::page')
22

33
@section('title', 'Create Menu')
44

5-
@section('content')
5+
@section('content_header')
66
<h1 class="page-title">
77
<i class="glyphicon glyphicon-list"></i> Create Menu
88
</h1>
9+
@stop
910

11+
@section('content')
1012
<form method="POST" action="{{ route('menu_arct.store') }}" class="form-horizontal">
1113
@csrf
1214
<div class="panel panel-default">
@@ -23,11 +25,11 @@
2325
@enderror
2426
</div>
2527
</div>
28+
<div class="text-right">
29+
<button type="submit" class="btn btn-primary">Submit</button>
30+
</div>
2631
</div>
2732
</div>
28-
<div class="text-right">
29-
<button type="submit" class="btn btn-primary">Submit</button>
30-
</div>
3133
</form>
3234

3335
@endsection

resources/views/menu/edit.blade.php

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
@extends('menu_architect::master')
1+
@extends('menu_architect::page')
22

33
@section('title', 'Edit Menu')
44

5-
@section('content')
5+
@section('content_header')
66
<h1 class="page-title">
77
<i class="glyphicon glyphicon-list"></i> Menu Item ({{ $model->data->name }})
88
</h1>
9+
@stop
10+
11+
@section('content')
912
<div class="alert alert-info">
1013
<strong>How To Use:</strong>
1114
<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>
1316
</p>
1417
</div>
1518

@@ -29,18 +32,18 @@
2932
@enderror
3033
</div>
3134
</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>
3239
</div>
3340
</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>
3841
</form>
3942

40-
<div class="box box-solid">
43+
<div class="box box-solid marct-builder">
4144
<div class="box-header with-border">
4245
<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">
4447
<i class="glyphicon glyphicon-plus"></i> Add New Item
4548
</button>
4649
</h3>
@@ -58,8 +61,8 @@
5861
</div>
5962
</div>
6063

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'))
6366

6467
@endsection
6568

@@ -94,10 +97,10 @@
9497
},
9598
toolRenderer: function (item_attrs_string, item) {
9699
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 + '>';
98101
html += '<i class="glyphicon glyphicon-edit"></i> Edit';
99102
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 + '>';
101104
html += '<i class="glyphicon glyphicon-trash"></i> Delete';
102105
html += '</a>';
103106
html += '</div>';
@@ -137,26 +140,36 @@
137140
children = item.children(nestable.options.listNodeName).children(nestable.options.itemNodeName);
138141
item.after(children);
139142
nestable.remove(data.id);
143+
Toast.fire({
144+
icon: 'success',
145+
title: 'remove success ' + data.label
146+
})
140147
})
141148
.on('ajax:beforeSend', '[data-rel="btnConfirm"]', function (event, xhr, settings) { /* */ })
142149
.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) {
145158
event.preventDefault();
146159
$('#editItemModal').modal('show', this);
147160
});
148161
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+
})
160173
161174
$('.modal[role="dialog"]')
162175
.on('shown.bs.modal', function (event) {
@@ -168,14 +181,15 @@
168181
modal.find('form').each(function ()
169182
{
170183
this.reset();
171-
if(action)
184+
if(action) {
172185
$(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+
}
175189
}
176190
});
177191
})
178-
.on('click', '.submit', function (event) {
192+
.on('click', '.marct-submit', function (event) {
179193
$(event.delegateTarget).modal('hide');
180194
$form = $(event.delegateTarget).find('form');
181195
$.ajax({
@@ -185,6 +199,8 @@
185199
}).done(function(data, status, xhr) {
186200
let nestable = $nestable.data('nestable'),
187201
item = nestable._getItemById(data.properties.id);
202+
if(data.properties.parent_id == 0)
203+
delete data.properties.parent_id;
188204
if(item.length > 0)
189205
nestable.replace(data.properties);
190206
else

resources/views/menu/index.blade.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@extends('menu_architect::master')
1+
@extends('menu_architect::page')
22

33
@section('title', 'Menu')
44

@@ -13,7 +13,7 @@
1313
<div class="alert alert-info">
1414
<strong>How To Use:</strong>
1515
<p>
16-
You can output a menu html anywhere on your site by calling <code>menu_arct('name')</code>, <a target="_blank" href="{{route('menu_arct.example')}}">see more examples.</a>
16+
You can output a menu html anywhere on your site by calling <code>menu_arct('name')</code>.</a>
1717
</p>
1818
</div>
1919

@@ -25,7 +25,7 @@
2525
<thead>
2626
<tr>
2727
<th width="100%">Name</th>
28-
<th nowrap>Actions</th>
28+
<th nowrap class="text-right">Actions</th>
2929
</tr>
3030
</thead>
3131
<tbody>
@@ -34,8 +34,9 @@
3434
<td>
3535
{{ $item->name }}
3636
</td>
37-
<td>
38-
<a href="{{ route('menu_arct.edit', [$item]) }}" class="btn btn-primary"><i class="glyphicon glyphicon-wrench"></i>&nbsp;Edit</a>
37+
<td nowrap class="text-right">
38+
<a href="{{ route('menu_arct.edit', [$item]) }}" class="btn btn-primary"><i class="glyphicon glyphicon-edit"></i>&nbsp;Edit</a>
39+
<a href="{{ route('menu_arct.destroy', [$item]) }}" data-rel="btnConfirm" data-timeout="2" data-confirm-text="Double touch to remove!" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i> Delete</a>
3940
</td>
4041
</tr>
4142
@endforeach
@@ -48,7 +49,14 @@
4849
@endsection
4950

5051
@section('js')
51-
52+
<script>
53+
$(function () {
54+
$(document.body)
55+
.on('ajax:success', '[data-rel="btnConfirm"]', function (event, data, status, xhr) {
56+
$(this).closest('tr').remove();
57+
});
58+
})
59+
</script>
5260
@endsection
5361

5462
@section('css')

resources/views/menu_item/index.blade.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

resources/views/page.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@extends('menu_architect::master')
2+
3+
@push('css')
4+
@include('menu_architect::plugins', ['type' => 'css'])
5+
@endpush
6+
7+
@push('js')
8+
@include('menu_architect::plugins', ['type' => 'js'])
9+
@endpush

routes.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@
2020
'items' => 'menu_arct_item'
2121
])
2222
->middleware(config('menu_architect.middleware'));
23-
24-
Route::get('menu_arct_example', MenuController::class . '@example')
25-
->name('menu_arct.example');

src/Controllers/MenuController.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,5 @@ public function update(Request $request, $id)
5454
public function destroy($id)
5555
{
5656
$this->m_rep->destroy($id);
57-
return redirect()->route('menu_arct.index');
58-
}
59-
60-
public function example()
61-
{
62-
return view('menu_architect::example');
6357
}
6458
}

0 commit comments

Comments
 (0)