@hashtagcms/admin-ui-kit 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/admin-ui-kit.min.css +14 -0
- package/dist/admin-ui-kit.min.js +2 -0
- package/dist/admin-ui-kit.min.js.LICENSE.txt +175 -0
- package/package.json +53 -0
- package/packages/components/README.md +92 -0
- package/packages/components/package.json +28 -0
- package/packages/components/src/action-bar.vue +237 -0
- package/packages/components/src/category-platform.vue +97 -0
- package/packages/components/src/category-settings.vue +815 -0
- package/packages/components/src/cms-module-dropdown.vue +78 -0
- package/packages/components/src/downlods.vue +21 -0
- package/packages/components/src/file-uploader.vue +188 -0
- package/packages/components/src/frontend-module-creator.vue +599 -0
- package/packages/components/src/global-site-button.vue +94 -0
- package/packages/components/src/homepage.vue +1087 -0
- package/packages/components/src/html-slot.vue +23 -0
- package/packages/components/src/image-gallery.vue +144 -0
- package/packages/components/src/index.js +53 -0
- package/packages/components/src/info-boxes.vue +68 -0
- package/packages/components/src/info-popup.vue +121 -0
- package/packages/components/src/language-button.vue +80 -0
- package/packages/components/src/language-copier.vue +177 -0
- package/packages/components/src/left-nav.vue +159 -0
- package/packages/components/src/library/copy-paste.vue +186 -0
- package/packages/components/src/library/info-box.vue +102 -0
- package/packages/components/src/library/left-menu-show-hide.vue +47 -0
- package/packages/components/src/library/loader.vue +141 -0
- package/packages/components/src/library/modal-box.vue +136 -0
- package/packages/components/src/library/split-button.vue +127 -0
- package/packages/components/src/library/timer-button.vue +43 -0
- package/packages/components/src/library/toast-box.vue +53 -0
- package/packages/components/src/menu-sorter.vue +265 -0
- package/packages/components/src/module-creator.vue +650 -0
- package/packages/components/src/module-permission.vue +334 -0
- package/packages/components/src/pagination.vue +125 -0
- package/packages/components/src/platform-button.vue +118 -0
- package/packages/components/src/search-bar.vue +144 -0
- package/packages/components/src/site-button.vue +42 -0
- package/packages/components/src/site-cloner.vue +150 -0
- package/packages/components/src/sitewise-copier.vue +234 -0
- package/packages/components/src/sitewise-data.vue +347 -0
- package/packages/components/src/sorter.vue +239 -0
- package/packages/components/src/tabular-view.vue +824 -0
- package/packages/components/src/title-bar.vue +76 -0
- package/packages/components/src/top-nav.vue +96 -0
- package/packages/helpers/README.md +88 -0
- package/packages/helpers/package.json +20 -0
- package/packages/helpers/src/admin-config.js +9 -0
- package/packages/helpers/src/common.js +89 -0
- package/packages/helpers/src/dashboard.js +16 -0
- package/packages/helpers/src/editor.js +163 -0
- package/packages/helpers/src/error-message-handler.js +50 -0
- package/packages/helpers/src/event-bus.js +4 -0
- package/packages/helpers/src/form.js +4 -0
- package/packages/helpers/src/fx.js +106 -0
- package/packages/helpers/src/humanize.js +14 -0
- package/packages/helpers/src/map.js +3 -0
- package/packages/styles/README.md +37 -0
- package/packages/styles/package.json +15 -0
- package/packages/styles/src/_action-bar.scss +35 -0
- package/packages/styles/src/_admin.scss +22 -0
- package/packages/styles/src/_animate.scss +1579 -0
- package/packages/styles/src/_badges.scss +34 -0
- package/packages/styles/src/_category-list.scss +14 -0
- package/packages/styles/src/_common.scss +163 -0
- package/packages/styles/src/_info-box.scss +96 -0
- package/packages/styles/src/_left-nav.scss +59 -0
- package/packages/styles/src/_loader.scss +82 -0
- package/packages/styles/src/_menu-sorter.scss +39 -0
- package/packages/styles/src/_model-creator.scss +48 -0
- package/packages/styles/src/_module-permission.scss +25 -0
- package/packages/styles/src/_page-manager.scss +63 -0
- package/packages/styles/src/_popover-modal.scss +20 -0
- package/packages/styles/src/_table-grid.scss +39 -0
- package/packages/styles/src/_toast.scss +20 -0
- package/packages/styles/src/_variables.scss +37 -0
- package/packages/styles/src/app.scss +2 -0
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div
|
|
4
|
+
v-show="
|
|
5
|
+
hasMicrosites || hasPlatformsMoreThanOne || hasPlatformsMoreThanOne
|
|
6
|
+
"
|
|
7
|
+
class="row"
|
|
8
|
+
>
|
|
9
|
+
<div v-show="hasMicrosites" class="col-auto">
|
|
10
|
+
<select
|
|
11
|
+
v-model="micrositeId"
|
|
12
|
+
class="form-select select"
|
|
13
|
+
@change="fetchNewData()"
|
|
14
|
+
>
|
|
15
|
+
<option value="0">Select a MicroSite</option>
|
|
16
|
+
<option v-for="microsite in siteMicrosites" :value="microsite.id">
|
|
17
|
+
{{ microsite.name }}
|
|
18
|
+
</option>
|
|
19
|
+
</select>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="col-auto">
|
|
22
|
+
<select
|
|
23
|
+
v-show="hasPlatformsMoreThanOne"
|
|
24
|
+
v-model="platformId"
|
|
25
|
+
class="form-select select"
|
|
26
|
+
@change="fetchNewData()"
|
|
27
|
+
>
|
|
28
|
+
<option>Select a Platform</option>
|
|
29
|
+
<option v-for="platform in sitePlatforms" :value="platform.id">
|
|
30
|
+
{{ platform.name }}
|
|
31
|
+
</option>
|
|
32
|
+
</select>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="col-auto">
|
|
35
|
+
<label
|
|
36
|
+
v-show="hasPlatformsMoreThanOne"
|
|
37
|
+
title="It will be inserted or deleted for all platforms if checks."
|
|
38
|
+
>
|
|
39
|
+
<input
|
|
40
|
+
v-model="applicableForAllPlatforms"
|
|
41
|
+
name="applicableForAll"
|
|
42
|
+
type="checkbox"
|
|
43
|
+
/>
|
|
44
|
+
Enable add/delete for all platforms</label
|
|
45
|
+
>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="row mt-3" v-if="!canEdit">
|
|
49
|
+
<div class="col-auto">
|
|
50
|
+
<p class="alert alert-warning">You have read only access.</p>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="row mt-3">
|
|
54
|
+
<div class="col-4">
|
|
55
|
+
<div class="panel panel-success shadow border">
|
|
56
|
+
<div class="panel-heading p-4">
|
|
57
|
+
<input
|
|
58
|
+
class="hide"
|
|
59
|
+
type="checkbox"
|
|
60
|
+
@click="selectAllData('allCategories', $event.target)"
|
|
61
|
+
/>
|
|
62
|
+
Drop in below panel to enable the category for this site.
|
|
63
|
+
<button
|
|
64
|
+
v-if="showUpdateAllBtn"
|
|
65
|
+
aria-label="More Info"
|
|
66
|
+
class="btn btn-default js_info icon-btn pull-right"
|
|
67
|
+
style="top: -7px; position: relative; right: -9px"
|
|
68
|
+
title="Update in all categories"
|
|
69
|
+
type="button"
|
|
70
|
+
@click="showUpdateAllDiv = !showUpdateAllDiv"
|
|
71
|
+
>
|
|
72
|
+
<i aria-hidden="true" class="fa fa-ellipsis-v js_info"></i>
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
<div
|
|
76
|
+
v-if="showUpdateAllDiv"
|
|
77
|
+
class="panel-body p-3"
|
|
78
|
+
style="background-color: #f3f3f3"
|
|
79
|
+
>
|
|
80
|
+
<p class="text-danger">
|
|
81
|
+
Be careful while using this. Changing this dropdown will effect to
|
|
82
|
+
all categories.
|
|
83
|
+
</p>
|
|
84
|
+
<select
|
|
85
|
+
v-model="globalTheme"
|
|
86
|
+
class="form-select margin-bottom-05"
|
|
87
|
+
@change="updateThemeToAllCategories()"
|
|
88
|
+
>
|
|
89
|
+
<option value="">Select a Theme</option>
|
|
90
|
+
<option v-for="theme in siteThemes" :value="theme.id">
|
|
91
|
+
{{ theme.name }}
|
|
92
|
+
</option>
|
|
93
|
+
</select>
|
|
94
|
+
</div>
|
|
95
|
+
<div
|
|
96
|
+
v-if="showSearch('allCategories')"
|
|
97
|
+
class="panel-sub-heading"
|
|
98
|
+
style="padding: 4px"
|
|
99
|
+
>
|
|
100
|
+
<div class="input-group">
|
|
101
|
+
<span class="input-group-addon">Search</span>
|
|
102
|
+
<input
|
|
103
|
+
v-model="searchKeyPlatformCategory"
|
|
104
|
+
aria-describedby="basic-addon3"
|
|
105
|
+
class="form-control"
|
|
106
|
+
placeholder="Search by id or name"
|
|
107
|
+
type="text"
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
<ul
|
|
112
|
+
ref="droppableArea"
|
|
113
|
+
class="list-group category-items js_category"
|
|
114
|
+
style="min-height: 200px"
|
|
115
|
+
>
|
|
116
|
+
<li
|
|
117
|
+
v-for="platformCategory in filterData('allCategories')"
|
|
118
|
+
:data-cache-category="platformCategory.cache_category"
|
|
119
|
+
:data-category-id="platformCategory.category_id"
|
|
120
|
+
:data-theme-id="platformCategory.theme_id"
|
|
121
|
+
class="list-group-item js_item"
|
|
122
|
+
@click="setCurrentSelection($event)"
|
|
123
|
+
>
|
|
124
|
+
<input
|
|
125
|
+
v-show="showCheckbox"
|
|
126
|
+
v-model="platformCategory.selected"
|
|
127
|
+
type="checkbox"
|
|
128
|
+
/>
|
|
129
|
+
{{ platformCategory.category_name }}
|
|
130
|
+
<small
|
|
131
|
+
v-show="platformCategory.theme_id > 0"
|
|
132
|
+
class="text-info"
|
|
133
|
+
title="Theme"
|
|
134
|
+
>
|
|
135
|
+
-
|
|
136
|
+
{{ getThemeName(platformCategory.theme_id) }}
|
|
137
|
+
</small>
|
|
138
|
+
<small
|
|
139
|
+
v-show="platformCategory.theme_id <= 0"
|
|
140
|
+
class="text-danger"
|
|
141
|
+
>
|
|
142
|
+
<br />Theme is missing</small
|
|
143
|
+
>
|
|
144
|
+
<span
|
|
145
|
+
class="btn-toolbar pull-right toolbar-category"
|
|
146
|
+
role="toolbar"
|
|
147
|
+
>
|
|
148
|
+
<span class="btn-group">
|
|
149
|
+
<button
|
|
150
|
+
v-if="canDelete"
|
|
151
|
+
aria-label="Delete from this platform"
|
|
152
|
+
class="btn btn-default icon-btn js_delete"
|
|
153
|
+
title="Delete from this platform"
|
|
154
|
+
type="button"
|
|
155
|
+
>
|
|
156
|
+
<span
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
class="fa fa-trash-o js_delete"
|
|
159
|
+
></span>
|
|
160
|
+
</button>
|
|
161
|
+
<button
|
|
162
|
+
v-if="canEdit"
|
|
163
|
+
aria-label="More Info"
|
|
164
|
+
class="btn btn-default js_info icon-btn"
|
|
165
|
+
title="More Info"
|
|
166
|
+
type="button"
|
|
167
|
+
>
|
|
168
|
+
<i aria-hidden="true" class="fa fa-ellipsis-v js_info"></i>
|
|
169
|
+
</button>
|
|
170
|
+
</span>
|
|
171
|
+
</span>
|
|
172
|
+
</li>
|
|
173
|
+
</ul>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
<div class="col-3">
|
|
177
|
+
<div class="panel panel-info margin-top-20">
|
|
178
|
+
<div class="panel-heading p-4">Drag and drop from here</div>
|
|
179
|
+
<div
|
|
180
|
+
v-if="showSearch('allSiteCategories')"
|
|
181
|
+
class="panel-sub-heading"
|
|
182
|
+
style="padding: 4px"
|
|
183
|
+
>
|
|
184
|
+
<div class="input-group">
|
|
185
|
+
<span class="input-group-addon">Search</span>
|
|
186
|
+
<input
|
|
187
|
+
v-model="searchKeyCategory"
|
|
188
|
+
aria-describedby="basic-addon3"
|
|
189
|
+
class="form-control"
|
|
190
|
+
placeholder="Search by id or name"
|
|
191
|
+
type="text"
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
<ul id="draggableItems" class="list-group">
|
|
196
|
+
<li
|
|
197
|
+
v-for="category in filterData('allSiteCategories')"
|
|
198
|
+
:data-category-id="category.category_id"
|
|
199
|
+
class="list-group-item js_item"
|
|
200
|
+
>
|
|
201
|
+
{{ category.category_name }}
|
|
202
|
+
</li>
|
|
203
|
+
</ul>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
<div
|
|
208
|
+
ref="popover"
|
|
209
|
+
class="popover hide bs-popover-end shadow"
|
|
210
|
+
data-popper-placement="right"
|
|
211
|
+
role="tooltip"
|
|
212
|
+
>
|
|
213
|
+
<p class="popover-header">
|
|
214
|
+
Set theme etc for this category
|
|
215
|
+
<span
|
|
216
|
+
aria-label="Close"
|
|
217
|
+
class="pull-right fa fa-close close"
|
|
218
|
+
title="Close"
|
|
219
|
+
@click="closePopup()"
|
|
220
|
+
></span>
|
|
221
|
+
</p>
|
|
222
|
+
<div class="popover-body">
|
|
223
|
+
<select v-model="currentSelection.theme_id" class="form-select mb-2">
|
|
224
|
+
<option value="">Select a Theme</option>
|
|
225
|
+
<option v-for="theme in siteThemes" :value="theme.id">
|
|
226
|
+
{{ theme.name }}
|
|
227
|
+
</option>
|
|
228
|
+
</select>
|
|
229
|
+
<input
|
|
230
|
+
v-model="currentSelection.cache_category"
|
|
231
|
+
class="form-control mb-2"
|
|
232
|
+
name="cache_category"
|
|
233
|
+
placeholder="Enter cache category"
|
|
234
|
+
type="text"
|
|
235
|
+
/>
|
|
236
|
+
<div class="text-center">
|
|
237
|
+
<button class="btn btn-primary text-center" @click="setThemeEtc()">
|
|
238
|
+
Save Settings
|
|
239
|
+
</button>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
</template>
|
|
245
|
+
|
|
246
|
+
<script>
|
|
247
|
+
import AdminConfig from "@hashtagcms/helpers/admin-config";
|
|
248
|
+
|
|
249
|
+
import Sortable from "sortablejs";
|
|
250
|
+
import { Toast } from "@hashtagcms/helpers/common";
|
|
251
|
+
|
|
252
|
+
export default {
|
|
253
|
+
mounted() {
|
|
254
|
+
this.init();
|
|
255
|
+
},
|
|
256
|
+
props: [
|
|
257
|
+
"dataSiteId",
|
|
258
|
+
"dataSitePlatforms",
|
|
259
|
+
"dataSiteCategories",
|
|
260
|
+
"dataSiteThemes",
|
|
261
|
+
"dataSiteMicrosites",
|
|
262
|
+
"dataPlatformId",
|
|
263
|
+
"dataMicrositeId",
|
|
264
|
+
"dataCategories",
|
|
265
|
+
"dataUserRights",
|
|
266
|
+
],
|
|
267
|
+
data() {
|
|
268
|
+
return {
|
|
269
|
+
checkAll: false,
|
|
270
|
+
showCheckbox: false,
|
|
271
|
+
sitePlatforms:
|
|
272
|
+
typeof this.dataSitePlatforms === "undefined" ||
|
|
273
|
+
this.dataSitePlatforms === ""
|
|
274
|
+
? []
|
|
275
|
+
: JSON.parse(this.dataSitePlatforms),
|
|
276
|
+
siteCategories:
|
|
277
|
+
typeof this.dataSiteCategories === "undefined" ||
|
|
278
|
+
this.dataSiteCategories === ""
|
|
279
|
+
? []
|
|
280
|
+
: JSON.parse(this.dataSiteCategories),
|
|
281
|
+
siteThemes:
|
|
282
|
+
typeof this.dataSiteThemes === "undefined" || this.dataSiteThemes === ""
|
|
283
|
+
? []
|
|
284
|
+
: JSON.parse(this.dataSiteThemes),
|
|
285
|
+
siteMicrosites:
|
|
286
|
+
typeof this.dataSiteMicrosites === "undefined" ||
|
|
287
|
+
this.dataSiteMicrosites === ""
|
|
288
|
+
? []
|
|
289
|
+
: JSON.parse(this.dataSiteMicrosites),
|
|
290
|
+
categories:
|
|
291
|
+
typeof this.dataCategories === "undefined" || this.dataCategories === ""
|
|
292
|
+
? []
|
|
293
|
+
: JSON.parse(this.dataCategories),
|
|
294
|
+
platformId:
|
|
295
|
+
typeof this.dataPlatformId === "undefined" || this.dataPlatformId === ""
|
|
296
|
+
? 1
|
|
297
|
+
: parseInt(this.dataPlatformId),
|
|
298
|
+
micrositeId:
|
|
299
|
+
typeof this.dataMicrositeId === "undefined" ||
|
|
300
|
+
this.dataMicrositeId === ""
|
|
301
|
+
? 0
|
|
302
|
+
: parseInt(this.dataMicrositeId),
|
|
303
|
+
searchKeyPlatformCategory: "",
|
|
304
|
+
searchKeyCategory: "",
|
|
305
|
+
applicableForAllPlatforms: false,
|
|
306
|
+
categoryId: 0,
|
|
307
|
+
currentSelection: { category_id: 0, theme_id: "", cache_category: "" },
|
|
308
|
+
allCategories: [],
|
|
309
|
+
allCategoriesInfo: {},
|
|
310
|
+
allSiteCategories: [],
|
|
311
|
+
siteId:
|
|
312
|
+
typeof this.dataSiteId === "undefined" ? 1 : parseInt(this.dataSiteId),
|
|
313
|
+
showUpdateAllBtn: true,
|
|
314
|
+
showUpdateAllDiv: false,
|
|
315
|
+
globalTheme: "",
|
|
316
|
+
userRights: this.dataUserRights ? JSON.parse(this.dataUserRights) : [],
|
|
317
|
+
};
|
|
318
|
+
},
|
|
319
|
+
computed: {
|
|
320
|
+
hasPlatformsMoreThanOne() {
|
|
321
|
+
return this.sitePlatforms.length > 1;
|
|
322
|
+
},
|
|
323
|
+
hasMicrosites() {
|
|
324
|
+
return this.siteMicrosites.length > 0;
|
|
325
|
+
},
|
|
326
|
+
canEdit() {
|
|
327
|
+
return this.userRights.indexOf("edit") >= 0;
|
|
328
|
+
},
|
|
329
|
+
canDelete() {
|
|
330
|
+
return this.userRights.indexOf("delete") >= 0;
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
methods: {
|
|
334
|
+
init() {
|
|
335
|
+
this.makeData();
|
|
336
|
+
if (this.canEdit) {
|
|
337
|
+
this.enableSorting();
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
selectAllData(findIn = "allCategories", holder) {
|
|
341
|
+
let $this = this;
|
|
342
|
+
let whereArr =
|
|
343
|
+
findIn === "allCategories"
|
|
344
|
+
? this.allCategories
|
|
345
|
+
: this.allSiteCategories;
|
|
346
|
+
let selected = holder.checked;
|
|
347
|
+
whereArr.forEach(function (current) {
|
|
348
|
+
$this.$set(current, "selected", selected);
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
makeData() {
|
|
352
|
+
let $this = this;
|
|
353
|
+
//this.allCategories = this.categories;
|
|
354
|
+
let categories = this.categories;
|
|
355
|
+
let selected = false;
|
|
356
|
+
if (categories.length > 0) {
|
|
357
|
+
categories.forEach(function (current) {
|
|
358
|
+
let category_id = current.category_id;
|
|
359
|
+
let category_name = current.lang.name || current.category_name;
|
|
360
|
+
let theme_id = current.theme_id;
|
|
361
|
+
let cache_category = current.cache_category;
|
|
362
|
+
let obj = {
|
|
363
|
+
category_id,
|
|
364
|
+
category_name,
|
|
365
|
+
theme_id,
|
|
366
|
+
cache_category,
|
|
367
|
+
selected,
|
|
368
|
+
};
|
|
369
|
+
$this.allCategories.push(obj);
|
|
370
|
+
$this.allCategoriesInfo[category_id.toString()] = obj;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
//Site Categories
|
|
374
|
+
categories = this.siteCategories;
|
|
375
|
+
//console.log("categories ", categories);
|
|
376
|
+
if (categories.length > 0) {
|
|
377
|
+
categories.forEach(function (current) {
|
|
378
|
+
let category_id = current.category_id;
|
|
379
|
+
let category_name = current.name;
|
|
380
|
+
let theme_id = "";
|
|
381
|
+
let cache_category = "";
|
|
382
|
+
let obj = {
|
|
383
|
+
category_id,
|
|
384
|
+
category_name,
|
|
385
|
+
theme_id,
|
|
386
|
+
cache_category,
|
|
387
|
+
selected,
|
|
388
|
+
};
|
|
389
|
+
$this.allSiteCategories.push(obj);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
//console.log($this.allSiteCategories);
|
|
394
|
+
},
|
|
395
|
+
getWhere() {
|
|
396
|
+
let where = {
|
|
397
|
+
microsite_id: this.micrositeId,
|
|
398
|
+
platform_id: this.platformId,
|
|
399
|
+
category_id: this.categoryId,
|
|
400
|
+
site_id: this.siteId,
|
|
401
|
+
};
|
|
402
|
+
return where;
|
|
403
|
+
},
|
|
404
|
+
saveNow(url, data) {
|
|
405
|
+
return new Promise((resolve, reject) => {
|
|
406
|
+
axios
|
|
407
|
+
.post(url, data)
|
|
408
|
+
.then((response) => {
|
|
409
|
+
resolve(response);
|
|
410
|
+
})
|
|
411
|
+
.catch((error) => {
|
|
412
|
+
reject(error.response);
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
},
|
|
416
|
+
updateIndex() {
|
|
417
|
+
let $this = this;
|
|
418
|
+
let allCategories = document.querySelectorAll(".js_category li");
|
|
419
|
+
let platformId = this.platformId;
|
|
420
|
+
let datas = [];
|
|
421
|
+
for (let i = 0; i < allCategories.length; i++) {
|
|
422
|
+
let current = allCategories[i];
|
|
423
|
+
//console.log("current ", current);
|
|
424
|
+
let categoryInfo = this.getCategoryInfo(
|
|
425
|
+
current.getAttribute("data-category-id"),
|
|
426
|
+
"allCategories",
|
|
427
|
+
);
|
|
428
|
+
//console.log("categoryInfo ", categoryInfo);
|
|
429
|
+
let data = { position: i + 1 };
|
|
430
|
+
let where = {
|
|
431
|
+
category_id: categoryInfo.category_id,
|
|
432
|
+
platform_id: platformId,
|
|
433
|
+
}; //microsite_id:
|
|
434
|
+
datas.push({ where, data });
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (datas.length > 0) {
|
|
438
|
+
let url = AdminConfig.admin_path("category/updateIndex");
|
|
439
|
+
let postParams = {};
|
|
440
|
+
postParams.data = datas;
|
|
441
|
+
//postParams.applicableForAllPlatforms = $this.applicableForAllPlatforms;
|
|
442
|
+
this.saveNow(url, postParams)
|
|
443
|
+
.then(function (res) {
|
|
444
|
+
//console.log(res);
|
|
445
|
+
Toast.show($this, "Saved...");
|
|
446
|
+
})
|
|
447
|
+
.catch(function (res) {
|
|
448
|
+
Toast.show($this, res.data.message, 2000);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
showSearch(findIn = "allCategories") {
|
|
453
|
+
let whereArr =
|
|
454
|
+
findIn === "allCategories"
|
|
455
|
+
? this.allCategories
|
|
456
|
+
: this.allSiteCategories;
|
|
457
|
+
return whereArr.length > 10;
|
|
458
|
+
},
|
|
459
|
+
filterData(findIn = "allCategories") {
|
|
460
|
+
let key =
|
|
461
|
+
findIn === "allCategories"
|
|
462
|
+
? this.searchKeyPlatformCategory
|
|
463
|
+
: this.searchKeyCategory;
|
|
464
|
+
let whereArr =
|
|
465
|
+
findIn === "allCategories"
|
|
466
|
+
? this.allCategories
|
|
467
|
+
: this.allSiteCategories;
|
|
468
|
+
if (key !== "" && key != null) {
|
|
469
|
+
key = key.toLowerCase();
|
|
470
|
+
|
|
471
|
+
return whereArr.filter(function (current) {
|
|
472
|
+
let name = current.category_name.toLowerCase();
|
|
473
|
+
let id = current.category_id;
|
|
474
|
+
if (id.toString() === key.toString() || name.includes(key)) {
|
|
475
|
+
return current;
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
} else {
|
|
479
|
+
// console.log("data", this.allData.data);
|
|
480
|
+
return findIn === "allCategories"
|
|
481
|
+
? this.allCategories
|
|
482
|
+
: this.allSiteCategories;
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
setCurrentSelection(evt) {
|
|
486
|
+
let target = evt.currentTarget;
|
|
487
|
+
let span = evt.target;
|
|
488
|
+
|
|
489
|
+
let category_id = target.getAttribute("data-category-id");
|
|
490
|
+
let theme_id = target.getAttribute("data-theme-id");
|
|
491
|
+
|
|
492
|
+
let categoryInfo = this.getCategoryInfo(category_id, "allCategories");
|
|
493
|
+
|
|
494
|
+
this.currentSelection.theme_id = theme_id;
|
|
495
|
+
this.currentSelection.category_id = category_id;
|
|
496
|
+
this.currentSelection.cache_category = categoryInfo.cache_category;
|
|
497
|
+
|
|
498
|
+
let action;
|
|
499
|
+
if (span.classList.contains("js_info")) {
|
|
500
|
+
action = "info";
|
|
501
|
+
showInfo(target, this.$refs.popover);
|
|
502
|
+
}
|
|
503
|
+
if (span.classList.contains("js_delete")) {
|
|
504
|
+
action = "delete";
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// console.log(this.currentSelection);
|
|
508
|
+
|
|
509
|
+
function showInfo(source, target, where = "center-right") {
|
|
510
|
+
target.classList.remove(...["animated", "fadeOut", "hide"]);
|
|
511
|
+
let src = source;
|
|
512
|
+
let tgt = target;
|
|
513
|
+
let srcOpt = src.getBoundingClientRect();
|
|
514
|
+
let tgtOpt = tgt.getBoundingClientRect();
|
|
515
|
+
|
|
516
|
+
let left = srcOpt.left + srcOpt.width;
|
|
517
|
+
let top = srcOpt.top + srcOpt.height - tgtOpt.height / 2;
|
|
518
|
+
|
|
519
|
+
target.classList.add(...["animated", "jello"]);
|
|
520
|
+
|
|
521
|
+
switch (where) {
|
|
522
|
+
case "center-right":
|
|
523
|
+
tgt.style.position = "absolute";
|
|
524
|
+
tgt.style.left = left + "px";
|
|
525
|
+
tgt.style.top = top + "px";
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
closePopup() {
|
|
531
|
+
this.$refs.popover.classList.add(...["animated", "fadeOut", "hide"]);
|
|
532
|
+
setTimeout(() => {});
|
|
533
|
+
},
|
|
534
|
+
fetchNewData() {
|
|
535
|
+
let where = this.getWhere();
|
|
536
|
+
delete where.category_id;
|
|
537
|
+
if (where.microsite_id === 0) {
|
|
538
|
+
delete where.microsite_id;
|
|
539
|
+
}
|
|
540
|
+
let url = "category/settings";
|
|
541
|
+
window.location.href = AdminConfig.admin_path(url, where);
|
|
542
|
+
},
|
|
543
|
+
enableSorting() {
|
|
544
|
+
let $this = this;
|
|
545
|
+
this.$nextTick(function () {
|
|
546
|
+
let list = document.querySelectorAll(".js_category");
|
|
547
|
+
list.forEach(function (current) {
|
|
548
|
+
Sortable.create(current, {
|
|
549
|
+
animation: 200,
|
|
550
|
+
filter: ".js_delete",
|
|
551
|
+
group: {
|
|
552
|
+
name: "droppable",
|
|
553
|
+
put: "modulesBox",
|
|
554
|
+
},
|
|
555
|
+
onFilter: function (evt) {
|
|
556
|
+
let item = evt.item,
|
|
557
|
+
ctrl = evt.target;
|
|
558
|
+
let id = item.getAttribute("data-category-id");
|
|
559
|
+
|
|
560
|
+
if (Sortable.utils.is(ctrl, ".js_delete")) {
|
|
561
|
+
// Click on remove button
|
|
562
|
+
$this.removeCategory(id);
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
onUpdate: function (/**Event*/ evt) {
|
|
566
|
+
//console.log("onUpdate ", evt);
|
|
567
|
+
$this.updateIndex();
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
//Right Side module
|
|
574
|
+
let draggableModules = document.getElementById("draggableItems");
|
|
575
|
+
|
|
576
|
+
Sortable.create(draggableModules, {
|
|
577
|
+
animation: 200,
|
|
578
|
+
draggable: ".js_item",
|
|
579
|
+
group: {
|
|
580
|
+
name: "modulesBox",
|
|
581
|
+
pull: "clone",
|
|
582
|
+
revertClone: true,
|
|
583
|
+
},
|
|
584
|
+
sort: false,
|
|
585
|
+
ghostClass: ".js_category",
|
|
586
|
+
onEnd: function (/**Event*/ evt) {
|
|
587
|
+
let to = evt.to;
|
|
588
|
+
let item = evt.item; // dragged HTMLElement
|
|
589
|
+
|
|
590
|
+
let categoryId = item.getAttribute("data-category-id");
|
|
591
|
+
|
|
592
|
+
if (categoryId) {
|
|
593
|
+
let categoryInfo = $this.getCategoryInfo(
|
|
594
|
+
categoryId,
|
|
595
|
+
"allSiteCategories",
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
//console.log("onEnd: categoryInfo ",categoryInfo);
|
|
599
|
+
|
|
600
|
+
let isAdded;
|
|
601
|
+
if (categoryInfo !== null) {
|
|
602
|
+
isAdded = $this.addCategory(categoryInfo);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
item.parentNode.removeChild(item);
|
|
606
|
+
|
|
607
|
+
$this.highlightEagerDrop("remove");
|
|
608
|
+
|
|
609
|
+
//we can send feedback
|
|
610
|
+
if (isAdded === false) {
|
|
611
|
+
Toast.show(
|
|
612
|
+
$this,
|
|
613
|
+
"Category is already added in this platform...",
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
onStart: function (/**Event*/ evt) {
|
|
619
|
+
$this.highlightEagerDrop("add");
|
|
620
|
+
},
|
|
621
|
+
});
|
|
622
|
+
},
|
|
623
|
+
highlightEagerDrop(addRemove = "add") {
|
|
624
|
+
let js_hook_modules = document.querySelectorAll(".js_category");
|
|
625
|
+
js_hook_modules.forEach(function (current) {
|
|
626
|
+
current.classList[addRemove]("module-drop-eager");
|
|
627
|
+
});
|
|
628
|
+
},
|
|
629
|
+
getCategoryInfo(categoryId, findIn = "allSiteCategories") {
|
|
630
|
+
let found = null;
|
|
631
|
+
let whereArr =
|
|
632
|
+
findIn === "allSiteCategories"
|
|
633
|
+
? this.allSiteCategories
|
|
634
|
+
: this.allCategories;
|
|
635
|
+
|
|
636
|
+
for (let i = 0; i < whereArr.length; i++) {
|
|
637
|
+
let current = whereArr[i];
|
|
638
|
+
if (parseInt(current.category_id) === parseInt(categoryId)) {
|
|
639
|
+
found = current;
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return found;
|
|
644
|
+
},
|
|
645
|
+
findIndex(categoryId, findIn = "allCategories") {
|
|
646
|
+
//allCategories is left site
|
|
647
|
+
let index = -1;
|
|
648
|
+
let whereArr =
|
|
649
|
+
findIn === "allCategories"
|
|
650
|
+
? this.allCategories
|
|
651
|
+
: this.allSiteCategories;
|
|
652
|
+
if (whereArr.length > 0) {
|
|
653
|
+
for (let i = 0; i < whereArr.length; i++) {
|
|
654
|
+
let current = whereArr[i];
|
|
655
|
+
if (parseInt(current.category_id) === parseInt(categoryId)) {
|
|
656
|
+
index = i;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return index;
|
|
662
|
+
},
|
|
663
|
+
addCategory(category) {
|
|
664
|
+
let $this = this;
|
|
665
|
+
let index = this.findIndex(category.category_id);
|
|
666
|
+
let isAdded = false;
|
|
667
|
+
if (index === -1) {
|
|
668
|
+
//add in info
|
|
669
|
+
this.allCategoriesInfo[category.category_id.toString()] = {
|
|
670
|
+
index: index,
|
|
671
|
+
info: category,
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
//save in db
|
|
675
|
+
setTimeout(function () {
|
|
676
|
+
updateInDB();
|
|
677
|
+
}, 1);
|
|
678
|
+
|
|
679
|
+
isAdded = this.allCategories.push(category);
|
|
680
|
+
|
|
681
|
+
//console.log("isAdded 2 ",isAdded);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return isAdded;
|
|
685
|
+
|
|
686
|
+
function updateInDB() {
|
|
687
|
+
let url = AdminConfig.admin_path("category/insertCategory");
|
|
688
|
+
let where = $this.getWhere();
|
|
689
|
+
let postParams = {};
|
|
690
|
+
delete category["name"];
|
|
691
|
+
category.platform_id = where.platform_id;
|
|
692
|
+
postParams.data = {
|
|
693
|
+
category_id: category.category_id,
|
|
694
|
+
platform_id: where.platform_id,
|
|
695
|
+
site_id: where.site_id,
|
|
696
|
+
};
|
|
697
|
+
postParams.applicableForAllPlatforms = $this.applicableForAllPlatforms;
|
|
698
|
+
$this
|
|
699
|
+
.saveNow(url, postParams)
|
|
700
|
+
.then(function (res) {
|
|
701
|
+
Toast.show($this, "Saved...");
|
|
702
|
+
})
|
|
703
|
+
.catch(function (res) {
|
|
704
|
+
Toast.show($this, res.data.message, 2000);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
setThemeEtc() {
|
|
709
|
+
let $this = this;
|
|
710
|
+
let current = this.currentSelection;
|
|
711
|
+
//set them in array
|
|
712
|
+
let index = this.findIndex(current.category_id);
|
|
713
|
+
|
|
714
|
+
if (index !== -1) {
|
|
715
|
+
this.allCategories[index].theme_id = current.theme_id;
|
|
716
|
+
this.allCategories[index].cache_category = current.cache_category;
|
|
717
|
+
this.categoryId = parseInt(current.category_id);
|
|
718
|
+
|
|
719
|
+
let postParams = {};
|
|
720
|
+
postParams.where = this.getWhere();
|
|
721
|
+
postParams.data = {
|
|
722
|
+
cache_category: current.cache_category || "",
|
|
723
|
+
theme_id: current.theme_id,
|
|
724
|
+
};
|
|
725
|
+
postParams.applicableForAllPlatforms = $this.applicableForAllPlatforms;
|
|
726
|
+
|
|
727
|
+
let url = AdminConfig.admin_path("category/updateThemeAndEtc");
|
|
728
|
+
this.saveNow(url, postParams)
|
|
729
|
+
.then(function (res) {
|
|
730
|
+
Toast.show($this, "Saved...");
|
|
731
|
+
})
|
|
732
|
+
.catch(function (res) {
|
|
733
|
+
Toast.show($this, res.data.message, 2000);
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
this.closePopup();
|
|
737
|
+
},
|
|
738
|
+
removeCategory(id) {
|
|
739
|
+
let $this = this;
|
|
740
|
+
let index = this.findIndex(id);
|
|
741
|
+
if (index !== -1) {
|
|
742
|
+
let categoryInfo = this.allCategories.splice(index, 1);
|
|
743
|
+
removeNow(categoryInfo[0]);
|
|
744
|
+
return categoryInfo;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function removeNow(categoryInfo) {
|
|
748
|
+
let url = AdminConfig.admin_path("category/deleteCategory");
|
|
749
|
+
let postParams = {};
|
|
750
|
+
let where = $this.getWhere();
|
|
751
|
+
|
|
752
|
+
postParams.where = {
|
|
753
|
+
category_id: categoryInfo.category_id,
|
|
754
|
+
microsite_id: where.microsite_id,
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
if (!$this.applicableForAllPlatforms) {
|
|
758
|
+
postParams.where.platform_id = where.platform_id;
|
|
759
|
+
}
|
|
760
|
+
$this
|
|
761
|
+
.saveNow(url, postParams)
|
|
762
|
+
.then(function (res) {
|
|
763
|
+
Toast.show($this, "Saved...");
|
|
764
|
+
})
|
|
765
|
+
.catch(function (res) {
|
|
766
|
+
Toast.show($this, res.data.message, 2000);
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
getThemeName(id) {
|
|
771
|
+
for (let i = 0; i < this.siteThemes.length; i++) {
|
|
772
|
+
if (this.siteThemes[i].id == id) {
|
|
773
|
+
return this.siteThemes[i].name;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return "";
|
|
777
|
+
},
|
|
778
|
+
updateThemeToAllCategories() {
|
|
779
|
+
let $this = this;
|
|
780
|
+
let url = AdminConfig.admin_path("category/updateThemeForAllCategories");
|
|
781
|
+
let categories = this.filterData("allCategories");
|
|
782
|
+
|
|
783
|
+
if (this.globalTheme !== "") {
|
|
784
|
+
if (categories.length > 0) {
|
|
785
|
+
let where = this.getWhere();
|
|
786
|
+
delete where.category_id;
|
|
787
|
+
delete where.microsite_id;
|
|
788
|
+
|
|
789
|
+
let postParams = {
|
|
790
|
+
data: { theme_id: this.globalTheme },
|
|
791
|
+
where: where,
|
|
792
|
+
};
|
|
793
|
+
Toast.show($this, "Please wait...");
|
|
794
|
+
this.saveNow(url, postParams)
|
|
795
|
+
.then(function (res) {
|
|
796
|
+
//console.log(res);
|
|
797
|
+
if (res.data["error"]) {
|
|
798
|
+
Toast.show($this, res.data.message, 5000);
|
|
799
|
+
} else {
|
|
800
|
+
Toast.show($this, "Saved");
|
|
801
|
+
for (let i = 0; i < categories.length; i++) {
|
|
802
|
+
categories[i].theme_id = $this.globalTheme;
|
|
803
|
+
//console.log(categories[i]);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
})
|
|
807
|
+
.catch(function (res) {
|
|
808
|
+
Toast.show($this, res.data.message, 2000);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
};
|
|
815
|
+
</script>
|