Skip to content

Commit

Permalink
Add feature Enable/Disable widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Mar 21, 2024
1 parent c769ff8 commit fdfa505
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 16 deletions.
2 changes: 1 addition & 1 deletion assets/vendor/manager/dist/index.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions assets/vendor/manager/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/vendor/manager/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup>
import { onMounted, ref } from 'vue';
import { onMounted, ref, inject } from 'vue';
const emit = defineEmits(['update:closeElement', 'update:selectElement']);
const props = defineProps(['form', 'system']);
const constant = inject('constant', {});
const currentFilter = ref('');
const addons = ref([]);
let filters = ['System'];
Expand All @@ -16,6 +17,9 @@ onMounted(()=> {
if (['component', 'banner', 'message'].includes(addon.type) && !props.system[addon.type]) {
return true;
}
if (addon.element_type === 'widget' && parseInt(constant.enable_widget) === 0) {
return true;
}
addon.category.forEach(cat => {
if (filters.includes(cat)) {
counter[cat]++;
Expand Down
1 change: 1 addition & 0 deletions framework/elements/articles/articles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_ARTICLES_DESC</description>
<icon>fa-regular fa-newspaper</icon>
<category>ASTROID_ELEMENT_CATEGORY_JOOMLA</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/banner/banner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<category>ASTROID_ELEMENT_CATEGORY_SYSTEM</category>
<color>#00B8D8</color>
<multiple>false</multiple>
<element_type>system</element_type>
</element>
1 change: 1 addition & 0 deletions framework/elements/button/button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_BUTTON_DESC</description>
<icon>fa-solid fa-toggle-on</icon>
<category>ASTROID_ELEMENT_CATEGORY_UTILITY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/component/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<info>ASTROID_ELEMENTS_COMPONENT_INFO</info>
<info label="Animation" property="animation"></info>
<multiple>false</multiple>
<element_type>system</element_type>
</element>
1 change: 1 addition & 0 deletions framework/elements/divider/divider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_DIVIDER_DESC</description>
<icon>fa-solid fa-xmarks-lines</icon>
<category>ASTROID_ELEMENT_CATEGORY_UTILITY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/grid/grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_GRID_DESC</description>
<icon>fa-solid fa-grip</icon>
<category>ASTROID_ELEMENT_CATEGORY_UTILITY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/heading/heading.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_HEADING_DESC</description>
<icon>fa-solid fa-heading</icon>
<category>ASTROID_ELEMENT_CATEGORY_TYPOGRAPHY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/icons/icons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_ICONS_DESC</description>
<icon>fa-solid fa-font-awesome</icon>
<category>ASTROID_ELEMENT_CATEGORY_UTILITY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/image/image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_IMAGE_DESC</description>
<icon>fa-regular fa-image</icon>
<category>ASTROID_ELEMENT_CATEGORY_MEDIA</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/imagegroup/imagegroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_IMAGE_GROUP_DESC</description>
<icon>fa-regular fa-images</icon>
<category>ASTROID_ELEMENT_CATEGORY_MEDIA</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
2 changes: 1 addition & 1 deletion framework/elements/message/message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<color>#17C671</color>
<info>TPL_ASTROID_SYSTEM_MESSAGES_LABEL</info>
<multiple>false</multiple>
<info label="Animation" property="animation"></info>
<element_type>system</element_type>
</element>
1 change: 1 addition & 0 deletions framework/elements/module_position/module_position.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<icon>fas fa-cube</icon>
<category>ASTROID_ELEMENT_CATEGORY_SYSTEM</category>
<color>#00B8D8</color>
<element_type>system</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/navigation/navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_NAVIGATION_DESC</description>
<icon>fa-solid fa-bars</icon>
<category>ASTROID_ELEMENT_CATEGORY_UTILITY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/slideshow/slideshow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_SLIDESHOW_DESC</description>
<icon>fa-solid fa-panorama</icon>
<category>ASTROID_ELEMENT_CATEGORY_MEDIA,ASTROID_ELEMENT_CATEGORY_UTILITY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/text/text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_TEXT_DESC</description>
<icon>fa-solid fa-feather</icon>
<category>ASTROID_ELEMENT_CATEGORY_TYPOGRAPHY</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
1 change: 1 addition & 0 deletions framework/elements/video_button/video_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<description>ASTROID_WIDGET_VIDEO_BUTTON_DESC</description>
<icon>fa-solid fa-video</icon>
<category>ASTROID_ELEMENT_CATEGORY_MEDIA</category>
<element_type>widget</element_type>
<form>
<fields>
<fieldset name="general-settings" label="TPL_ASTROID_GENERAL_SETTINGS_LABEL" addfieldpath="/libraries/astroid/framework/fields">
Expand Down
2 changes: 2 additions & 0 deletions framework/library/astroid/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ protected function manager()
$document->addScript('vendor/manager/dist/index.js', 'body', [], [], 'module');
$pluginParams = Helper::getPluginParams();
$plg_color_mode = $pluginParams->get('astroid_color_mode_enable', 0);
$enable_widget = $pluginParams->get('astroid_enable_widgets', 1);

$config = [
'site_url' => Uri::root(),
Expand All @@ -143,6 +144,7 @@ protected function manager()
'template_name' => $template->template.'-'.$template->id,
'tpl_template_name' => $template->template,
'template_title' => $template->title,
'enable_widget' => $enable_widget,
'astroid_version' => Helper\Constants::$astroid_version,
'astroid_link' => Helper\Constants::$astroid_link,
'document_link' => Helper\Constants::$documentation_link,
Expand Down
3 changes: 3 additions & 0 deletions framework/library/astroid/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Element
public bool $multiple = true;
public string $classname = '';
public string $description = '';
public string $element_type = 'system';
protected string $xml_file = '';
protected string $default_xml_file = '';
protected string $layout = '';
Expand Down Expand Up @@ -119,6 +120,7 @@ protected function loadXML(): void
$category = (string) @$xml->category;

$this->title = $title;
$this->element_type = (string) @$xml->element_type;
$this->icon = $icon;
$this->category = explode(',', $category);
for ($i = 0 ; $i < count($this->category); $i++) {
Expand Down Expand Up @@ -169,6 +171,7 @@ public function getInfo(): array
'title' => Text::_($this->title),
'icon' => $this->icon,
'category' => $this->category,
'element_type' => $this->element_type,
'description' => Text::_($this->description),
'color' => $this->color,
'multiple' => $this->multiple,
Expand Down
2 changes: 2 additions & 0 deletions language/en-GB/en-GB.astroid.ini
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ TPL_ASTROID_OPEN_GRAPH_TITLE_LABEL="Open Graph"
TPL_ASTROID_PAGE_SETTING_MAIN_TITLE_LABEL="Page Settings"
TPL_ASTROID_BASIC_ENABLE_COLOR_MODE_LABEL="Color Mode"
ASTROID_BASIC_ENABLE_COLOR_MODE_DESC="Enable or disable the color mode."
TPL_ASTROID_BASIC_ENABLE_WIDGETS_LABEL="Enable Widgets"
TPL_ASTROID_BASIC_ENABLE_WIDGETS_DESC="Enable or disable the Widgets"
TPL_ASTROID_BASIC_REMOVE_GENERATOR_LABEL="Remove Generator"
TPL_ASTROID_BASIC_REMOVE_GENERATOR_DESC="Remove Generator Tag"
TPL_ASTROID_BASIC_ENABLE_COLOR_MODE_DESC="To enable Color Mode.<br />Go to Administrator > System Dashboard > Plugins > Astroid Plugin > Color Mode - Select 'Yes'"
Expand Down

0 comments on commit fdfa505

Please sign in to comment.