@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,334 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-if="superAdmin" class="alert alert-info">
|
|
4
|
+
<strong>{{ userModules.name }}</strong> is admin or super admin. No need
|
|
5
|
+
to provide module access.
|
|
6
|
+
</div>
|
|
7
|
+
<div v-if="superAdmin" class="row">
|
|
8
|
+
<div class="form-group center-align">
|
|
9
|
+
<a :href="dataBackUrl" class="btn btn-outline-primary">Okay :)</a>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<form
|
|
13
|
+
v-if="!superAdmin"
|
|
14
|
+
:action="permissionSaveUrl"
|
|
15
|
+
class="form-horizontal"
|
|
16
|
+
method="post"
|
|
17
|
+
role="form"
|
|
18
|
+
v-on:submit.prevent="saveData"
|
|
19
|
+
>
|
|
20
|
+
<div class="checkbox title">
|
|
21
|
+
<h4>
|
|
22
|
+
<label>
|
|
23
|
+
<input
|
|
24
|
+
v-model="selectAllModule"
|
|
25
|
+
type="checkbox"
|
|
26
|
+
@click="selectAll()"
|
|
27
|
+
/>
|
|
28
|
+
Select
|
|
29
|
+
</label>
|
|
30
|
+
modules for
|
|
31
|
+
<span class="text-info"
|
|
32
|
+
>{{ userModules.name }} {{ userModules.last_name }}</span
|
|
33
|
+
>
|
|
34
|
+
</h4>
|
|
35
|
+
</div>
|
|
36
|
+
<ul class="list-unstyled list-permission">
|
|
37
|
+
<li class="clearfix" v-for="module in form.cmsModuleData">
|
|
38
|
+
<div v-if="isParent(module)" class="row p-2">
|
|
39
|
+
<div class="col">
|
|
40
|
+
<input
|
|
41
|
+
@click="selectMe(module)"
|
|
42
|
+
class="form-check-input"
|
|
43
|
+
type="checkbox"
|
|
44
|
+
v-model="module.selected"
|
|
45
|
+
:id="'check_' + module.id"
|
|
46
|
+
:data-id="module.id"
|
|
47
|
+
data-is-parent="true"
|
|
48
|
+
/>
|
|
49
|
+
<label class="form-check-label" :for="'check_' + module.id"
|
|
50
|
+
> {{ module.name }}</label
|
|
51
|
+
>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="col-auto">
|
|
54
|
+
<label>
|
|
55
|
+
<input
|
|
56
|
+
:id="'check_readonly_' + module.id"
|
|
57
|
+
v-model="module.readonly"
|
|
58
|
+
type="checkbox"
|
|
59
|
+
@click="selectReadOnly(module, $event)"
|
|
60
|
+
data-is-readonly-checkbox="true"
|
|
61
|
+
/>
|
|
62
|
+
Read Only</label
|
|
63
|
+
>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<ul
|
|
67
|
+
v-if="hasChild(module)"
|
|
68
|
+
class="list-unstyled clearfix"
|
|
69
|
+
style="margin-left: 20px"
|
|
70
|
+
>
|
|
71
|
+
<li v-for="child in module.child" class="clearfix">
|
|
72
|
+
<div class="row p-2">
|
|
73
|
+
<div class="col">
|
|
74
|
+
<input
|
|
75
|
+
@click="selectMe(child, module)"
|
|
76
|
+
class="form-check-input"
|
|
77
|
+
type="checkbox"
|
|
78
|
+
v-model="child.selected"
|
|
79
|
+
:id="'check_' + child.id"
|
|
80
|
+
:data-id="child.id"
|
|
81
|
+
data-is-parent="false"
|
|
82
|
+
/>
|
|
83
|
+
<label
|
|
84
|
+
class="form-check-label"
|
|
85
|
+
:for="'check_' + child.id"
|
|
86
|
+
data-is-readonly="true"
|
|
87
|
+
> {{ child.name }}</label
|
|
88
|
+
>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="col-auto">
|
|
91
|
+
<label>
|
|
92
|
+
<input
|
|
93
|
+
:id="'check_readonly_' + child.id"
|
|
94
|
+
v-model="child.readonly"
|
|
95
|
+
type="checkbox"
|
|
96
|
+
@click="selectReadOnly(child, $event, true)"
|
|
97
|
+
data-is-readonly-checkbox="true"
|
|
98
|
+
/>
|
|
99
|
+
Read Only</label
|
|
100
|
+
>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</li>
|
|
104
|
+
</ul>
|
|
105
|
+
</li>
|
|
106
|
+
</ul>
|
|
107
|
+
|
|
108
|
+
<div class="row">
|
|
109
|
+
<div v-if="errorMessage !== ''" class="alert alert-danger">
|
|
110
|
+
{{ errorMessage }}
|
|
111
|
+
</div>
|
|
112
|
+
<div class="form-group center-align">
|
|
113
|
+
<input
|
|
114
|
+
class="btn btn-success btn-from-submit"
|
|
115
|
+
name="submit"
|
|
116
|
+
type="submit"
|
|
117
|
+
value="Save"
|
|
118
|
+
/>
|
|
119
|
+
<a :href="dataBackUrl" class="btn btn-outline-secondary">Back</a>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
</form>
|
|
123
|
+
</div>
|
|
124
|
+
</template>
|
|
125
|
+
|
|
126
|
+
<script>
|
|
127
|
+
import AdminConfig from "@hashtagcms/helpers/admin-config";
|
|
128
|
+
|
|
129
|
+
import Form from "@hashtagcms/helpers/form";
|
|
130
|
+
import { Toast } from "@hashtagcms/helpers/common";
|
|
131
|
+
import { EventBus } from "@hashtagcms/helpers/event-bus";
|
|
132
|
+
|
|
133
|
+
export default {
|
|
134
|
+
mounted() {
|
|
135
|
+
this.form.cmsModuleData = this.allModules;
|
|
136
|
+
this.form.userId = this.userModules.id;
|
|
137
|
+
this.showSuperAdmin();
|
|
138
|
+
EventBus.on("on-paste", (data) => {
|
|
139
|
+
this.handlePaste(data);
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
props: [
|
|
143
|
+
"dataCmsModules",
|
|
144
|
+
"dataUserModules",
|
|
145
|
+
"dataControllerName",
|
|
146
|
+
"dataBackUrl",
|
|
147
|
+
"dataIsSuperAdmin",
|
|
148
|
+
],
|
|
149
|
+
data() {
|
|
150
|
+
return {
|
|
151
|
+
userModules: this.dataUserModules ? JSON.parse(this.dataUserModules) : [],
|
|
152
|
+
form: new Form({
|
|
153
|
+
cmsModuleData: [],
|
|
154
|
+
userId: 0,
|
|
155
|
+
}),
|
|
156
|
+
selectAllModule: false,
|
|
157
|
+
superAdmin: false,
|
|
158
|
+
errorMessage: "",
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
computed: {
|
|
162
|
+
allModules() {
|
|
163
|
+
let userModules = this.userModules.cmsmodules;
|
|
164
|
+
|
|
165
|
+
let modules = this.dataCmsModules ? JSON.parse(this.dataCmsModules) : [];
|
|
166
|
+
//console.log(modules);
|
|
167
|
+
let filterModules = [];
|
|
168
|
+
if (modules.length > 0) {
|
|
169
|
+
for (let i = 0; i < modules.length; i++) {
|
|
170
|
+
let current = modules[i];
|
|
171
|
+
let found = findModule(current);
|
|
172
|
+
current.selected = found ? true : false;
|
|
173
|
+
current.readonly = found.readonly === 1;
|
|
174
|
+
if (current.parent_id === 0 && current.child.length > 0) {
|
|
175
|
+
for (let c = 0; c < current.child.length; c++) {
|
|
176
|
+
let child = current.child[c];
|
|
177
|
+
let foundChild = findModule(child);
|
|
178
|
+
child.selected = foundChild ? true : false;
|
|
179
|
+
child.readonly = foundChild.readonly === 1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (current.parent_id === 0) {
|
|
183
|
+
filterModules.push(current);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return filterModules;
|
|
188
|
+
|
|
189
|
+
function findModule(currentModule) {
|
|
190
|
+
if (userModules.length > 0) {
|
|
191
|
+
let found = userModules.find(function (current) {
|
|
192
|
+
return current.module_id.toString() === currentModule.id.toString();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return found === undefined ? false : found;
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
permissionSaveUrl() {
|
|
201
|
+
return AdminConfig.admin_path(
|
|
202
|
+
this.dataControllerName + "/saveModulePermissions",
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
csrfToken() {
|
|
206
|
+
return window.Laravel.csrfToken;
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
methods: {
|
|
210
|
+
handlePaste(data) {
|
|
211
|
+
let pastedData;
|
|
212
|
+
pastedData = JSON.parse(data);
|
|
213
|
+
this.form.cmsModuleData.forEach((item, index) => {
|
|
214
|
+
let id = item.id;
|
|
215
|
+
let status = isCheckBoxSelected(id);
|
|
216
|
+
if (status.selected) {
|
|
217
|
+
item.selected = true;
|
|
218
|
+
item.readonly = status.readonly;
|
|
219
|
+
}
|
|
220
|
+
if (item.child.length > 0) {
|
|
221
|
+
item.child.forEach((childItem, childIndex) => {
|
|
222
|
+
let childId = childItem.id;
|
|
223
|
+
let statusChild = isCheckBoxSelected(childId);
|
|
224
|
+
if (statusChild.selected) {
|
|
225
|
+
childItem.selected = true;
|
|
226
|
+
childItem.readonly = statusChild.readonly;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
function isCheckBoxSelected(id) {
|
|
233
|
+
for (let key in pastedData) {
|
|
234
|
+
let ele = document.getElementById("check_" + id);
|
|
235
|
+
let readonlyEle = document.getElementById("check_readonly_" + id);
|
|
236
|
+
if (ele && ele.checked) {
|
|
237
|
+
return { selected: true, readonly: readonlyEle.checked };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { selected: false, readonly: false };
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
hasChild(data) {
|
|
244
|
+
return data.child && data.child.length > 0;
|
|
245
|
+
},
|
|
246
|
+
isParent(data) {
|
|
247
|
+
return data.parent_id === 0;
|
|
248
|
+
},
|
|
249
|
+
selectReadOnly(current, event, isChild = false) {
|
|
250
|
+
let isChecked = event.target.checked;
|
|
251
|
+
if (current.selected !== true) {
|
|
252
|
+
current.selected = isChecked;
|
|
253
|
+
}
|
|
254
|
+
//current.readonly = (isChecked) ? 1 : 0;
|
|
255
|
+
if (isChild === true) {
|
|
256
|
+
//selected parent
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
selectAll() {
|
|
260
|
+
let shouldSelect = this.selectAllModule === false;
|
|
261
|
+
|
|
262
|
+
for (let i = 0; i < this.form.cmsModuleData.length; i++) {
|
|
263
|
+
let current = this.form.cmsModuleData[i];
|
|
264
|
+
current.selected = shouldSelect;
|
|
265
|
+
|
|
266
|
+
this.selectMe(current, undefined, shouldSelect);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
selectMe(current, parentModule, forcedSelectAll = null) {
|
|
270
|
+
let shouldSelect = current.selected === false; //show previous state
|
|
271
|
+
|
|
272
|
+
//if forcing
|
|
273
|
+
if (forcedSelectAll !== null) {
|
|
274
|
+
shouldSelect = forcedSelectAll;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (current.child && current.child.length > 0) {
|
|
278
|
+
current.child.map(function (c) {
|
|
279
|
+
c.selected = shouldSelect;
|
|
280
|
+
//reset readonly
|
|
281
|
+
if (!shouldSelect) {
|
|
282
|
+
c.readonly = false;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (shouldSelect !== true) {
|
|
288
|
+
current.readonly = false;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
//check if parent should be selected
|
|
292
|
+
if (parentModule) {
|
|
293
|
+
let isAnySelected = parentModule.child.find(function (current) {
|
|
294
|
+
//console.log("current.selected === true", current.selected === true)
|
|
295
|
+
return current.selected === true;
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
if (shouldSelect || isAnySelected) {
|
|
299
|
+
parentModule.selected = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
//Check if one or more is unchecked. reset select all tab
|
|
304
|
+
if (shouldSelect === false) {
|
|
305
|
+
this.selectAllModule = false;
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
showSuperAdmin() {
|
|
309
|
+
if (
|
|
310
|
+
this.dataIsSuperAdmin.toString() === "1" ||
|
|
311
|
+
this.dataIsSuperAdmin.toString() === "true"
|
|
312
|
+
) {
|
|
313
|
+
this.superAdmin = true;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
saveData() {
|
|
317
|
+
this.form
|
|
318
|
+
.post(this.permissionSaveUrl, false)
|
|
319
|
+
.then((response) => this.afterFormSaved(response))
|
|
320
|
+
.catch((response) => this.afterFormSaved(response));
|
|
321
|
+
},
|
|
322
|
+
afterFormSaved(response) {
|
|
323
|
+
if (response.isSaved === true) {
|
|
324
|
+
Toast.show(this, "Saved Successfully. ");
|
|
325
|
+
} else {
|
|
326
|
+
Toast.show(this, "There is some error.");
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
goBack() {
|
|
330
|
+
window.location = this.dataBackUrl;
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
</script>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="row">
|
|
3
|
+
<div class="col-auto">
|
|
4
|
+
<span class="counters" v-if="totalCount > 0">
|
|
5
|
+
{{ dataFirstItem }} - {{ lastItem }} of {{ totalCount }}
|
|
6
|
+
</span>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="col-auto">
|
|
9
|
+
<nav v-if="showPagination" class="shadow-sm">
|
|
10
|
+
<ul class="pagination">
|
|
11
|
+
<li v-for="page in allPages" :class="getCss(page)">
|
|
12
|
+
<a
|
|
13
|
+
class="page-link"
|
|
14
|
+
:href="getLink(page)"
|
|
15
|
+
v-html="getLabel(page.label)"
|
|
16
|
+
></a>
|
|
17
|
+
</li>
|
|
18
|
+
</ul>
|
|
19
|
+
</nav>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="col float-end" v-if="totalCount > 0 && showDownload">
|
|
22
|
+
<span class="pull-right" style="margin-right: 16px">
|
|
23
|
+
<download-button
|
|
24
|
+
:data-controller-name="controllerName"
|
|
25
|
+
></download-button>
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
import { EventBus } from "@hashtagcms/helpers/event-bus";
|
|
33
|
+
import DownloadButton from "./downlods.vue";
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
components: {
|
|
37
|
+
"download-button": DownloadButton,
|
|
38
|
+
},
|
|
39
|
+
mounted() {
|
|
40
|
+
this.updatePageParams();
|
|
41
|
+
let $this = this;
|
|
42
|
+
EventBus.on("pagination-on-delete", function () {
|
|
43
|
+
$this.decreaseCounter();
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
props: [
|
|
47
|
+
"dataPaginator",
|
|
48
|
+
"dataFirstItem",
|
|
49
|
+
"dataLastItem",
|
|
50
|
+
"dataTotal",
|
|
51
|
+
"dataControllerName",
|
|
52
|
+
"dataNextLabel",
|
|
53
|
+
"dataPreviousLabel",
|
|
54
|
+
"dataShowDownload",
|
|
55
|
+
],
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
totalCount: parseInt(this.dataTotal),
|
|
59
|
+
lastItem: parseInt(this.dataLastItem),
|
|
60
|
+
controllerName: this.dataControllerName,
|
|
61
|
+
paginator: JSON.parse(this.dataPaginator),
|
|
62
|
+
pageLabel: {
|
|
63
|
+
"pagination.next": this.dataNextLabel,
|
|
64
|
+
"pagination.previous": this.dataPreviousLabel,
|
|
65
|
+
},
|
|
66
|
+
showDownload:
|
|
67
|
+
this.dataShowDownload === "true" || this.dataShowDownload === "1",
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
computed: {
|
|
71
|
+
hasPreviousPage() {
|
|
72
|
+
return this.paginator.prev_page_url != null;
|
|
73
|
+
},
|
|
74
|
+
allPages() {
|
|
75
|
+
return this.paginator.links;
|
|
76
|
+
},
|
|
77
|
+
showPagination() {
|
|
78
|
+
return this.allPages.length > 3; //["Previous", "1", "Next"]
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
methods: {
|
|
82
|
+
decreaseCounter() {
|
|
83
|
+
this.totalCount = this.totalCount - 1;
|
|
84
|
+
this.lastItem = this.lastItem - 1;
|
|
85
|
+
},
|
|
86
|
+
getLink(page) {
|
|
87
|
+
return page.url == null ? "javascript:void(0)" : page.url;
|
|
88
|
+
},
|
|
89
|
+
getLabel(label) {
|
|
90
|
+
//label is provided from view file
|
|
91
|
+
if (this.pageLabel[label]) {
|
|
92
|
+
return this.pageLabel[label];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return label;
|
|
96
|
+
},
|
|
97
|
+
getCss(page) {
|
|
98
|
+
if (page.url == null) {
|
|
99
|
+
return "page-item disabled";
|
|
100
|
+
}
|
|
101
|
+
return page.active === true ? "page-item active" : "page-item";
|
|
102
|
+
},
|
|
103
|
+
updatePageParams() {
|
|
104
|
+
let params = window.location.search.substring(1);
|
|
105
|
+
// console.log("params "+params);
|
|
106
|
+
let hasPage = params.match(/page=\d+/gi);
|
|
107
|
+
if (hasPage != null) {
|
|
108
|
+
params = params.replace(/page=\d+/, "");
|
|
109
|
+
}
|
|
110
|
+
if (params !== "") {
|
|
111
|
+
params = params.indexOf("&") === 0 ? params : "&" + params;
|
|
112
|
+
let elements = document.querySelectorAll(".pagination a");
|
|
113
|
+
elements.forEach(function (ele, index) {
|
|
114
|
+
let href = ele.href;
|
|
115
|
+
href = href + "" + params;
|
|
116
|
+
//remove last and double &
|
|
117
|
+
href = href.replace(/&$/, "");
|
|
118
|
+
href = href.replace(/&&/, "&");
|
|
119
|
+
ele.href = href;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
</script>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<select
|
|
4
|
+
:name="name"
|
|
5
|
+
:id="id"
|
|
6
|
+
@change="setPlatform"
|
|
7
|
+
v-model="selected"
|
|
8
|
+
:multiple="dataMultiple == 'true' ? multiple : false"
|
|
9
|
+
>
|
|
10
|
+
<option value="">Select Platform</option>
|
|
11
|
+
<option v-for="platform in platforms" :value="platform.id">
|
|
12
|
+
{{ platform.name }}
|
|
13
|
+
</option>
|
|
14
|
+
</select>
|
|
15
|
+
<i v-show="isLoading" class="fa fa-refresh fa-spin" aria-hidden="true"></i>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import AdminConfig from "@hashtagcms/helpers/admin-config";
|
|
21
|
+
import SplitButton from "./library/split-button.vue";
|
|
22
|
+
import { EventBus } from "@hashtagcms/helpers/event-bus";
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
components: {
|
|
26
|
+
"split-button": SplitButton,
|
|
27
|
+
},
|
|
28
|
+
props: [
|
|
29
|
+
"dataName",
|
|
30
|
+
"dataId",
|
|
31
|
+
"dataPlatforms",
|
|
32
|
+
"dataSelected",
|
|
33
|
+
"dataMultiple",
|
|
34
|
+
"dataSiteId",
|
|
35
|
+
"dataFetchOnInit",
|
|
36
|
+
],
|
|
37
|
+
mounted() {
|
|
38
|
+
if (this.fetchOnInit !== false) {
|
|
39
|
+
this.init();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log("selected ", this.selected);
|
|
43
|
+
|
|
44
|
+
EventBus.$on("site_changed", this.populatePlatform);
|
|
45
|
+
},
|
|
46
|
+
computed: {
|
|
47
|
+
selected: {
|
|
48
|
+
get() {
|
|
49
|
+
//if this is not multiple
|
|
50
|
+
if (
|
|
51
|
+
typeof this.dataMultiple === "undefined" ||
|
|
52
|
+
this.dataMultiple !== "true"
|
|
53
|
+
) {
|
|
54
|
+
return typeof this.dataSelected === "undefined"
|
|
55
|
+
? 1
|
|
56
|
+
: parseInt(this.dataSelected);
|
|
57
|
+
}
|
|
58
|
+
//this is multiple
|
|
59
|
+
return typeof this.dataSelected === "undefined"
|
|
60
|
+
? [1]
|
|
61
|
+
: JSON.parse(this.dataSelected);
|
|
62
|
+
},
|
|
63
|
+
set(newValue) {
|
|
64
|
+
return newValue;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
data() {
|
|
69
|
+
return {
|
|
70
|
+
platforms:
|
|
71
|
+
typeof this.dataPlatforms === "undefined"
|
|
72
|
+
? []
|
|
73
|
+
: JSON.parse(this.dataPlatforms),
|
|
74
|
+
name:
|
|
75
|
+
typeof this.dataName === "undefined" ? "platform_id" : this.dataName,
|
|
76
|
+
id: typeof this.dataId === "undefined" ? "platform_id" : this.dataId,
|
|
77
|
+
multiple:
|
|
78
|
+
typeof this.dataMultiple === "undefined" ? "" : "multiple='multiple'",
|
|
79
|
+
siteId:
|
|
80
|
+
typeof this.dataSiteId === "undefined" ? 1 : parseInt(this.dataSiteId),
|
|
81
|
+
fetchOnInit:
|
|
82
|
+
typeof this.dataFetchOnInit === "undefined" ||
|
|
83
|
+
this.dataFetchOnInit === "false"
|
|
84
|
+
? false
|
|
85
|
+
: this.dataFetchOnInit,
|
|
86
|
+
isLoading: false,
|
|
87
|
+
selectedValue: this.selected,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
methods: {
|
|
91
|
+
init() {
|
|
92
|
+
this.populatePlatform(this.siteId);
|
|
93
|
+
},
|
|
94
|
+
setPlatform() {
|
|
95
|
+
EventBus.$emit("platform_changed", this.selected);
|
|
96
|
+
},
|
|
97
|
+
populatePlatform(siteId = null) {
|
|
98
|
+
if (siteId === null || siteId === "") {
|
|
99
|
+
this.platforms = [];
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
this.isLoading = true;
|
|
103
|
+
|
|
104
|
+
let $this = this;
|
|
105
|
+
let platformUrl = AdminConfig.admin_path("ajax/getInfo/site/" + siteId);
|
|
106
|
+
axios
|
|
107
|
+
.get(platformUrl)
|
|
108
|
+
.then(function (res) {
|
|
109
|
+
$this.platforms = res.data.results.platform;
|
|
110
|
+
$this.isLoading = false;
|
|
111
|
+
})
|
|
112
|
+
.catch(function (res) {
|
|
113
|
+
console.error(res.data);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
</script>
|