Skip to content

Commit 545e329

Browse files
committed
2 parents b4ddb44 + ab709ab commit 545e329

File tree

23 files changed

+1383
-845
lines changed

23 files changed

+1383
-845
lines changed

src/assets/data/permissions.json

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"modules": [
3+
{
4+
"id": "cms",
5+
"name": "Content Management",
6+
"groups": [
7+
{
8+
"id": "pages",
9+
"name": "Pages Management",
10+
"permissions": [
11+
{ "id": "view_pages", "name": "View Pages" },
12+
{ "id": "add_pages", "name": "Create New Pages" },
13+
{ "id": "edit_pages", "name": "Edit Pages" },
14+
{ "id": "delete_pages", "name": "Delete Pages" },
15+
{ "id": "restore_pages", "name": "Restore Deleted Pages" },
16+
{ "id": "publish_pages", "name": "Publish/Unpublish Pages" }
17+
]
18+
},
19+
{
20+
"id": "posts",
21+
"name": "Posts Management",
22+
"permissions": [
23+
{ "id": "view_posts", "name": "View Posts" },
24+
{ "id": "add_posts", "name": "Create New Posts" },
25+
{ "id": "edit_posts", "name": "Edit Posts" },
26+
{ "id": "delete_posts", "name": "Delete Posts" },
27+
{ "id": "restore_posts", "name": "Restore Deleted Posts" },
28+
{ "id": "publish_posts", "name": "Publish/Unpublish Posts" }
29+
]
30+
},
31+
{
32+
"id": "media",
33+
"name": "Media Library",
34+
"permissions": [
35+
{ "id": "view_media", "name": "View Media Files" },
36+
{ "id": "upload_media", "name": "Upload Media Files" },
37+
{ "id": "edit_media", "name": "Edit Media Details" },
38+
{ "id": "delete_media", "name": "Delete Media Files" },
39+
{ "id": "restore_media", "name": "Restore Deleted Media" }
40+
]
41+
},
42+
{
43+
"id": "categories",
44+
"name": "Categories Management",
45+
"permissions": [
46+
{ "id": "view_categories", "name": "View Categories" },
47+
{ "id": "add_categories", "name": "Create Categories" },
48+
{ "id": "edit_categories", "name": "Edit Categories" },
49+
{ "id": "delete_categories", "name": "Delete Categories" },
50+
{ "id": "restore_categories", "name": "Restore Categories" }
51+
]
52+
}
53+
]
54+
},
55+
{
56+
"id": "seo",
57+
"name": "Search Engine Optimization",
58+
"groups": [
59+
{
60+
"id": "seo_settings",
61+
"name": "SEO Settings",
62+
"permissions": [
63+
{ "id": "view_seo_settings", "name": "View SEO Settings" },
64+
{ "id": "edit_seo_settings", "name": "Edit SEO Settings" },
65+
{ "id": "manage_meta_tags", "name": "Manage Meta Tags" },
66+
{ "id": "manage_sitemaps", "name": "Manage Sitemaps" }
67+
]
68+
},
69+
{
70+
"id": "redirects",
71+
"name": "URL Redirects",
72+
"permissions": [
73+
{ "id": "view_redirects", "name": "View Redirects" },
74+
{ "id": "add_redirects", "name": "Add Redirects" },
75+
{ "id": "edit_redirects", "name": "Edit Redirects" },
76+
{ "id": "delete_redirects", "name": "Delete Redirects" }
77+
]
78+
},
79+
{
80+
"id": "analytics",
81+
"name": "Analytics",
82+
"permissions": [
83+
{ "id": "view_analytics", "name": "View Analytics Dashboard" },
84+
{ "id": "export_analytics", "name": "Export Analytics Data" },
85+
{ "id": "manage_analytics_settings", "name": "Manage Analytics Settings" }
86+
]
87+
}
88+
]
89+
},
90+
{
91+
"id": "system",
92+
"name": "System Administration",
93+
"groups": [
94+
{
95+
"id": "users",
96+
"name": "User Management",
97+
"permissions": [
98+
{ "id": "view_users", "name": "View Users" },
99+
{ "id": "add_users", "name": "Create Users" },
100+
{ "id": "edit_users", "name": "Edit Users" },
101+
{ "id": "delete_users", "name": "Delete Users" },
102+
{ "id": "restore_users", "name": "Restore Users" },
103+
{ "id": "block_users", "name": "Block/Unblock Users" }
104+
]
105+
},
106+
{
107+
"id": "roles",
108+
"name": "Role Management",
109+
"permissions": [
110+
{ "id": "view_roles", "name": "View Roles" },
111+
{ "id": "add_roles", "name": "Create Roles" },
112+
{ "id": "edit_roles", "name": "Edit Roles" },
113+
{ "id": "delete_roles", "name": "Delete Roles" },
114+
{ "id": "assign_permissions", "name": "Assign Role Permissions" }
115+
]
116+
},
117+
{
118+
"id": "settings",
119+
"name": "System Settings",
120+
"permissions": [
121+
{ "id": "view_settings", "name": "View System Settings" },
122+
{ "id": "edit_settings", "name": "Edit System Settings" },
123+
{ "id": "manage_backups", "name": "Manage System Backups" },
124+
{ "id": "manage_cache", "name": "Manage System Cache" }
125+
]
126+
},
127+
{
128+
"id": "logs",
129+
"name": "System Logs",
130+
"permissions": [
131+
{ "id": "view_logs", "name": "View System Logs" },
132+
{ "id": "delete_logs", "name": "Delete System Logs" },
133+
{ "id": "export_logs", "name": "Export System Logs" }
134+
]
135+
}
136+
]
137+
}
138+
]
139+
}

src/assets/js/pages/roles-permissions/groups/table.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ var GroupsDatatable = (function () {
180180
if ($(".form-check-input:checked").length > 0) {
181181
$(".form-check-input").prop("checked", false)
182182
}
183+
if ($("#filterDrawer .form-select").length > 0) {
184+
$("#filterDrawer .form-select").val("")
185+
}
183186

184187
$('[data-table-filter="search"]').val("")
185188
$(".search-clear").hide()

src/assets/js/pages/roles-permissions/permissions/table.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ var PermissionsDatatable = (function () {
203203
if ($(".form-check-input:checked").length > 0) {
204204
$(".form-check-input").prop("checked", false)
205205
}
206-
206+
if ($("#filterDrawer .form-select").length > 0) {
207+
$("#filterDrawer .form-select").val("")
208+
}
209+
207210
$('[data-table-filter="search"]').val("")
208211
$(".search-clear").hide()
209212
$("#module").val("")

src/assets/js/pages/tables/datatable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getAssetPrefix } from "../../../js/path-utils.js";
22
("use strict")
33

44
let data_url = getAssetPrefix("/assets/data/products.json")
5-
let assetpath = getAssetPrefix("/assets/")
5+
let assetpath = getAssetPrefix("/assets")
66

77
let pageindex = 0 // Default to first page if not specified
88

src/assets/js/pages/users/list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ var UsersDatatable = (function () {
231231
if ($(".form-check-input:checked").length > 0) {
232232
$(".form-check-input").prop("checked", false)
233233
}
234-
if ($(".form-select").length > 0) {
235-
$(".form-select").val("")
234+
if ($("#filterDrawer .form-select").length > 0) {
235+
$("#filterDrawer .form-select").val("")
236236
}
237237

238238
$('[data-table-filter="search"]').val("")

src/assets/js/path-utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @returns {string} The prefixed path
55
*/
66
export function getPathPrefix(path) {
7-
const isDev = !window.location.pathname.includes("pages/")
7+
const isDev = window.location.port === '1234'
88
return isDev ? `${path}` : `/pages${path}`
99
}
1010

@@ -14,6 +14,6 @@ export function getPathPrefix(path) {
1414
* @returns {string} The prefixed asset path
1515
*/
1616
export function getAssetPrefix(path) {
17-
const isDev = !window.location.pathname.includes("pages/")
17+
const isDev = window.location.port === '1234'
1818
return isDev ? `/dist${path}` : `${path}`
1919
}

src/assets/vendor/js/component-preview/preview-manager.js

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -28,63 +28,73 @@ window.PreviewManager = class PreviewManager {
2828

2929
const iframe = previewBox.querySelector('.preview-iframe')
3030
if (!iframe) return
31-
31+
3232
// Debounce updates by preview box
3333
const previewBoxId = previewBox.id || 'default'
3434
this.debounceByPreviewBox(previewBoxId, () => {
3535
try {
36-
// Get all editors
37-
const htmlEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'html')
38-
const cssEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'css')
39-
const jsEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'javascript')
40-
41-
// Validate editors and content
42-
const validateEditor = (editor, type) => {
43-
if (!editor) return ''
44-
try {
45-
const value = editor.getValue()
46-
return typeof value === 'string' ? value : ''
47-
} catch (err) {
48-
console.error(`Error getting ${type} content:`, err)
49-
return ''
36+
// Check if using external source
37+
const externalSrc = previewBox.dataset.externalSrc
38+
if (externalSrc) {
39+
// For external sources, only update if src has changed
40+
if (iframe.src !== externalSrc) {
41+
//iframe.src = externalSrc
42+
}
43+
}else{
44+
// Get all editors
45+
const htmlEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'html')
46+
const cssEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'css')
47+
const jsEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'javascript')
48+
49+
// Validate editors and content
50+
const validateEditor = (editor, type) => {
51+
if (!editor) return ''
52+
try {
53+
const value = editor.getValue()
54+
return typeof value === 'string' ? value : ''
55+
} catch (err) {
56+
console.error(`Error getting ${type} content:`, err)
57+
return ''
58+
}
5059
}
51-
}
5260

53-
const htmlContent = validateEditor(htmlEditor, 'HTML')
54-
const cssContent = validateEditor(cssEditor, 'CSS')
55-
const jsContent = validateEditor(jsEditor, 'JavaScript')
56-
57-
// Get theme
58-
const themeToggle = previewBox.querySelector('.theme-toggle')
59-
const theme = themeToggle?.dataset.currentTheme || 'light'
60-
61-
// Update iframe content with error handling
62-
if (iframe.contentWindow) {
63-
try {
64-
iframe.contentWindow.postMessage({
65-
type: 'updateContent',
66-
html: htmlContent,
67-
css: cssContent,
68-
js: jsContent
69-
}, '*')
70-
71-
iframe.contentWindow.postMessage({ type: 'setTheme', theme: theme }, '*')
72-
73-
// Clear any previous error messages
74-
const errorContainer = previewBox.querySelector('.preview-update-container')
75-
if (errorContainer) {
76-
errorContainer.classList.add('d-none')
61+
const htmlContent = validateEditor(htmlEditor, 'HTML')
62+
const cssContent = validateEditor(cssEditor, 'CSS')
63+
const jsContent = validateEditor(jsEditor, 'JavaScript')
64+
65+
// Get theme
66+
const themeToggle = previewBox.querySelector('.theme-toggle')
67+
const theme = themeToggle?.dataset.currentTheme || 'light'
68+
69+
// Update iframe content with error handling
70+
if (iframe.contentWindow) {
71+
try {
72+
iframe.contentWindow.postMessage({
73+
type: 'updateContent',
74+
html: htmlContent,
75+
css: cssContent,
76+
js: jsContent
77+
}, '*')
78+
79+
iframe.contentWindow.postMessage({ type: 'setTheme', theme: theme }, '*')
80+
81+
// Clear any previous error messages
82+
const errorContainer = previewBox.querySelector('.preview-update-container')
83+
if (errorContainer) {
84+
errorContainer.classList.add('d-none')
85+
}
86+
} catch (err) {
87+
console.error('Error updating iframe content:', err)
88+
this.showError(previewBox, 'Failed to update preview: ' + err.message)
7789
}
78-
} catch (err) {
79-
console.error('Error updating iframe content:', err)
80-
this.showError(previewBox, 'Failed to update preview: ' + err.message)
90+
} else {
91+
// Fallback to full refresh if contentWindow is not available
92+
const iframeContent = this.createIframeContent(htmlContent, cssContent, jsContent, theme)
93+
iframe.srcdoc = iframeContent
8194
}
82-
} else {
83-
// Fallback to full refresh if contentWindow is not available
84-
const iframeContent = this.createIframeContent(htmlContent, cssContent, jsContent, theme)
85-
iframe.srcdoc = iframeContent
8695
}
8796

97+
8898
// Sync with other previews
8999
this.syncPreviewContent(previewBox)
90100
} catch (err) {
@@ -122,6 +132,17 @@ window.PreviewManager = class PreviewManager {
122132
const iframe = previewBox.querySelector('.preview-iframe')
123133
if (!iframe) return
124134

135+
// Check if using external source
136+
const externalSrc = previewBox.dataset.externalSrc
137+
if (externalSrc) {
138+
// For external sources, only update if src has changed
139+
if (iframe.src !== externalSrc) {
140+
//iframe.src = externalSrc
141+
}
142+
return
143+
}
144+
145+
// For non-external sources, proceed with full content update
125146
// Get all editors
126147
const htmlEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'html')
127148
const cssEditor = window.CodeMirrorManager?.getEditorFromPreviewBox(previewBox, 'css')
@@ -189,6 +210,20 @@ window.PreviewManager = class PreviewManager {
189210
}
190211

191212
static syncPreviewContent(previewBox) {
213+
// Check if using external source
214+
const externalSrc = previewBox.dataset.externalSrc
215+
if (externalSrc) {
216+
// For external sources, only sync theme
217+
const themeToggle = previewBox.querySelector('.theme-toggle')
218+
const currentTheme = themeToggle?.dataset.currentTheme || 'light'
219+
220+
if (typeof window.UIControlsManager !== 'undefined') {
221+
window.UIControlsManager.updateComponentTheme(previewBox, currentTheme)
222+
}
223+
return
224+
}
225+
226+
// For non-external sources, proceed with full content sync
192227
if (previewBox.classList.contains('preview-box')) {
193228
const modalId = previewBox.dataset.modal ||
194229
previewBox.querySelector(".preview-expand")?.getAttribute("data-bs-target")?.replace('#', '')

0 commit comments

Comments
 (0)