|
30 | 30 | </style> |
31 | 31 |
|
32 | 32 | <script> |
33 | | - import draggable from 'vuedraggable' |
| 33 | +import draggable from 'vuedraggable' |
34 | 34 |
|
35 | | - export default { |
36 | | - name: 'menu-child', |
37 | | - props: ['pages', 'allPages', 'locale', 'delChild', 'childs'], |
38 | | - components: {draggable}, |
39 | | - methods: { |
40 | | - deleteChild(item){ |
41 | | - $.post(this.delChild,{ |
42 | | - child_id: item.id, |
43 | | - }, (res) => { |
44 | | - if (res.done) { |
45 | | - this.childs.splice(this.childs.indexOf(item), 1) |
| 35 | +export default { |
| 36 | + name: 'menu-child', |
| 37 | + props: ['pages', 'allPages', 'locale', 'delChild', 'childs'], |
| 38 | + components: {draggable}, |
| 39 | + methods: { |
| 40 | + deleteChild(item) { |
| 41 | + $.post(this.delChild, { |
| 42 | + child_id: item.id |
| 43 | + }, (res) => { |
| 44 | + if (res.done) { |
| 45 | + this.childs.splice(this.childs.indexOf(item), 1) |
46 | 46 |
|
47 | | - EventHub.fire('showNotif',{ |
48 | | - title: 'Success', |
49 | | - body: `"${this.getTitle(item.title)}" was removed`, |
50 | | - type: 'success', |
51 | | - duration: 3, |
52 | | - icon: false |
53 | | - }); |
| 47 | + EventHub.fire('showNotif', { |
| 48 | + title: 'Success', |
| 49 | + body: `"${this.getTitle(item.title)}" was removed`, |
| 50 | + type: 'success', |
| 51 | + duration: 3, |
| 52 | + icon: false |
| 53 | + }) |
54 | 54 |
|
55 | | - EventHub.fire('updateAllPages') |
56 | | - EventHub.fire('updatePagesHierarchy') |
57 | | - } |
58 | | - }) |
59 | | - }, |
60 | | - getTitle(title) { |
61 | | - let locale = this.locale |
62 | | - let v = Object.keys(title).indexOf(locale) |
63 | | - return title.hasOwnProperty(locale) ? Object.values(title)[v] : Object.values(title)[0] |
64 | | - }, |
65 | | -
|
66 | | - // operations |
67 | | - checkFrom(item) { |
68 | | - return item.from ? true : false; |
69 | | - }, |
70 | | - undoItem(item) { |
71 | | - this.childs.splice(this.childs.indexOf(item),1) |
72 | | - this.pushBackToList(item) |
73 | | - }, |
74 | | - pushBackToList(item){ |
75 | | - return item.from == 'pages' ? this.pages.unshift(item) : this.allPages.unshift(item) |
76 | | - }, |
77 | | -
|
78 | | - // nests |
79 | | - hasChilds(item){ |
80 | | - return item.nests && item.nests.length > 0; |
81 | | - }, |
82 | | - checkAdded(e){ |
83 | | - // update saveList on nest movement |
84 | | - if (e.removed || e.added && e.added.element.from == 'allPages') { |
| 55 | + EventHub.fire('updateAllPages') |
85 | 56 | EventHub.fire('updatePagesHierarchy') |
86 | 57 | } |
87 | | - } |
| 58 | + }) |
| 59 | + }, |
| 60 | + getTitle(title) { |
| 61 | + let locale = this.locale |
| 62 | + let v = Object.keys(title).indexOf(locale) |
| 63 | + return title.hasOwnProperty(locale) ? Object.values(title)[v] : Object.values(title)[0] |
| 64 | + }, |
| 65 | +
|
| 66 | + // operations |
| 67 | + checkFrom(item) { |
| 68 | + return item.from ? true : false |
88 | 69 | }, |
| 70 | + undoItem(item) { |
| 71 | + this.childs.splice(this.childs.indexOf(item), 1) |
| 72 | + this.pushBackToList(item) |
| 73 | + }, |
| 74 | + pushBackToList(item) { |
| 75 | + return item.from == 'pages' ? this.pages.unshift(item) : this.allPages.unshift(item) |
| 76 | + }, |
| 77 | +
|
| 78 | + // nests |
| 79 | + hasChilds(item) { |
| 80 | + return item.nests && item.nests.length > 0 |
| 81 | + }, |
| 82 | + checkAdded(e) { |
| 83 | + // update saveList on nest movement |
| 84 | + if (e.moved || e.removed || e.added && e.added.element.from == 'allPages') { |
| 85 | + EventHub.fire('updatePagesHierarchy') |
| 86 | + } |
| 87 | + } |
89 | 88 | } |
| 89 | +} |
90 | 90 | </script> |
0 commit comments