From 1063e1da19f49bb755944ae4ae9b0caa10d4057c Mon Sep 17 00:00:00 2001 From: astridx Date: Fri, 30 Apr 2021 12:33:40 +0200 Subject: [PATCH] wip --- j4/pkg_agosms/package-lock.json | 6 + j4/pkg_agosms/package.json | 1 + .../com_agosms/language/de-DE/com_agosms.ini | 54 ++++- .../com_agosms/language/en-GB/com_agosms.ini | 5 + .../com_agosms/src/View/Agosms/HtmlView.php | 5 + .../com_agosms/src/View/Foo/HtmlView.php | 145 ------------ .../com_agosms/src/View/Foos/HtmlView.php | 206 ------------------ .../com_agosms/tmpl/agosms/emptystate.php | 29 +++ 8 files changed, 94 insertions(+), 357 deletions(-) create mode 100644 j4/pkg_agosms/package-lock.json create mode 100644 j4/pkg_agosms/package.json delete mode 100644 j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foo/HtmlView.php delete mode 100644 j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foos/HtmlView.php create mode 100644 j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php diff --git a/j4/pkg_agosms/package-lock.json b/j4/pkg_agosms/package-lock.json new file mode 100644 index 00000000..c64b0c82 --- /dev/null +++ b/j4/pkg_agosms/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "pkg_agosms", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/j4/pkg_agosms/package.json b/j4/pkg_agosms/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/j4/pkg_agosms/package.json @@ -0,0 +1 @@ +{} diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/language/de-DE/com_agosms.ini b/j4/pkg_agosms/src/administrator/components/com_agosms/language/de-DE/com_agosms.ini index 6569dd74..7d61eada 100644 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/language/de-DE/com_agosms.ini +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/language/de-DE/com_agosms.ini @@ -1,16 +1,58 @@ COM_AGOSMS="[PROJECT_NAME]" -COM_AGOSMS_CONFIGURATION="Agosm Optionen" +COM_AGOSMS_CONFIGURATION="Agosm Options" +COM_AGOSMS_AGOSMS="Agosms" +COM_AGOSMS_CATEGORIES="Categories" -COM_AGOSMS_MANAGER_AGOSM_NEW="Neu" -COM_AGOSMS_MANAGER_AGOSM_EDIT="Bearbeiten" +COM_AGOSMS_MANAGER_AGOSM_NEW="New" +COM_AGOSMS_MANAGER_AGOSM_EDIT="Edit" COM_AGOSMS_MANAGER_AGOSMS="Agosm Manager" COM_AGOSMS_TABLE_TABLEHEAD_NAME="Name" COM_AGOSMS_TABLE_TABLEHEAD_ID="ID" -COM_AGOSMS_ERROR_AGOSM_NOT_FOUND="Agosm nicht gefunden" +COM_AGOSMS_ERROR_AGOSM_NOT_FOUND="Agosm not found" COM_AGOSMS_FIELD_NAME_LABEL="Name" -COM_AGOSMS_FIELD_AGOSM_SHOW_CATEGORY_LABEL="Namensschild anzeigen" -COM_AGOSMS_FIELD_CONFIG_INDIVIDUAL_AGOSM_DESC="Diese Einstellungen gelten für alle agosm." +COM_AGOSMS_FIELD_AGOSM_SHOW_CATEGORY_LABEL="Show name label" +COM_AGOSMS_FIELD_CONFIG_INDIVIDUAL_AGOSM_DESC="These settings apply for all agosm." COM_AGOSMS_FIELD_CONFIG_INDIVIDUAL_AGOSM_DISPLAY="Agosm" + +COM_AGOSMS_FIELD_PUBLISH_DOWN_LABEL="Finish Publishing" +COM_AGOSMS_FIELD_PUBLISH_UP_LABEL="Start Publishing" +COM_AGOSMS_N_ITEMS_PUBLISHED="%d agosms published." +COM_AGOSMS_N_ITEMS_PUBLISHED_1="%d agosm published." +COM_AGOSMS_N_ITEMS_UNPUBLISHED="%d agosms unpublished." +COM_AGOSMS_N_ITEMS_UNPUBLISHED_1="%d agosm unpublished." +COM_AGOSMS_N_ITEMS_CHECKED_IN_1="%d agosm checked in." +COM_AGOSMS_N_ITEMS_CHECKED_IN_MORE="%d agosms checked in." +COM_AGOSMS_N_ITEMS_FEATURED="%d agosms featured." +COM_AGOSMS_N_ITEMS_FEATURED_1="Agosm featured." +COM_AGOSMS_N_ITEMS_UNFEATURED="%d agosms unfeatured." +COM_AGOSMS_N_ITEMS_UNFEATURED_1="Agosm unfeatured." + +COM_AGOSMS_EDIT_AGOSM="Edit Agosm" +COM_AGOSMS_NEW_AGOSM="New Agosm" + +COM_AGOSMS_HEADING_ASSOCIATION="Association" +COM_AGOSMS_CHANGE_AGOSM="Change a agosm" +COM_AGOSMS_SELECT_A_AGOSM="Select a agosm" + +COM_AGOSMS_TABLE_CAPTION="Agosm Table Caption" + +COM_AGOSMS_N_ITEMS_ARCHIVED="%d agosms archived." +COM_AGOSMS_N_ITEMS_ARCHIVED_1="%d agosm archived." +COM_AGOSMS_N_ITEMS_DELETED="%d agosms deleted." +COM_AGOSMS_N_ITEMS_DELETED_1="%d agosm deleted." +COM_AGOSMS_N_ITEMS_TRASHED="%d agosms trashed." +COM_AGOSMS_N_ITEMS_TRASHED_1="%d agosm trashed." +COM_AGOSM_MANAGER_AGOSMS="Agosms" + +COM_AGOSMS_FIELD_PARAMS_NAME_LABEL="Show Name" + +COM_AGOSMS_FILTER_SEARCH_DESC="Search in agosm name." +COM_AGOSMS_FILTER_SEARCH_LABEL="Search Agosms" + +COM_AGOSMS_EMPTYSTATE_BUTTON_ADD="Add your first item" +COM_AGOSMS_EMPTYSTATE_BUTTON_LEARNMORE="Learn more" +COM_AGOSMS_EMPTYSTATE_CONTENT="Agosms Artikel bauen eine Bildkarte auf. Diese kann so einfach wie ein Point of Interests (POI) oder so komplex wie die ganze Welt sein. Sie können diese Komponente verwenden, um Ihre Karte zu erstellen und zu verwalten." +COM_AGOSMS_EMPTYSTATE_TITLE="No item have been created yet." diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/language/en-GB/com_agosms.ini b/j4/pkg_agosms/src/administrator/components/com_agosms/language/en-GB/com_agosms.ini index cb5bdd13..aec863b2 100644 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/language/en-GB/com_agosms.ini +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/language/en-GB/com_agosms.ini @@ -51,3 +51,8 @@ COM_AGOSMS_FIELD_PARAMS_NAME_LABEL="Show Name" COM_AGOSMS_FILTER_SEARCH_DESC="Search in agosm name." COM_AGOSMS_FILTER_SEARCH_LABEL="Search Agosms" + +COM_AGOSMS_EMPTYSTATE_BUTTON_ADD="Add your first item" +COM_AGOSMS_EMPTYSTATE_BUTTON_LEARNMORE="Learn more" +COM_AGOSMS_EMPTYSTATE_CONTENT="Agosms items build an image map. This can be as simple as one point of interesst (POI) or as complex as the whole world. You can use this component to create and manage your map." +COM_AGOSMS_EMPTYSTATE_TITLE="No item have been created yet." diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Agosms/HtmlView.php b/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Agosms/HtmlView.php index d507369d..723d7897 100644 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Agosms/HtmlView.php +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Agosms/HtmlView.php @@ -87,6 +87,11 @@ public function display($tpl = null): void $this->activeFilters = $this->get('ActiveFilters'); $this->state = $this->get('State'); + if (!count($this->items) && $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // Check for errors. if (count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors), 500); diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foo/HtmlView.php b/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foo/HtmlView.php deleted file mode 100644 index 544917d9..00000000 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foo/HtmlView.php +++ /dev/null @@ -1,145 +0,0 @@ -form = $this->get('Form'); - $this->item = $this->get('Item'); - - // If we are forcing a language in modal (used for associations). - if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'cmd')) { - // Set the language field to the forcedLanguage and disable changing it. - $this->form->setValue('language', null, $forcedLanguage); - $this->form->setFieldAttribute('language', 'readonly', 'true'); - - // Only allow to select categories with All language or with the forced language. - $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage); - - // Only allow to select tags with All language or with the forced language. - $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage); - } - - $this->addToolbar(); - - return parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @return void - * - * @since __BUMP_VERSION__ - */ - protected function addToolbar() - { - Factory::getApplication()->input->set('hidemainmenu', true); - - $user = Factory::getUser(); - $userId = $user->id; - - $isNew = ($this->item->id == 0); - - ToolbarHelper::title($isNew ? Text::_('COM_AGOSMS_MANAGER_AGOSM_NEW') : Text::_('COM_AGOSMS_MANAGER_AGOSM_EDIT'), 'address agosm'); - - // Since we don't track these assets at the item level, use the category id. - $canDo = ContentHelper::getActions('com_agosms', 'category', $this->item->catid); - - // Build the actions for new and existing records. - if ($isNew) { - // For new records, check the create permission. - if ($isNew && (count($user->getAuthorisedCategories('com_agosms', 'core.create')) > 0)) { - ToolbarHelper::apply('agosm.apply'); - ToolbarHelper::saveGroup( - [ - ['save', 'agosm.save'], - ['save2new', 'agosm.save2new'] - ], - 'btn-success' - ); - } - - ToolbarHelper::cancel('agosm.cancel'); - } else { - // Since it's an existing record, check the edit permission, or fall back to edit own if the owner. - $itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId); - $toolbarButtons = []; - - // Can't save the record if it's not editable - if ($itemEditable) { - ToolbarHelper::apply('agosm.apply'); - $toolbarButtons[] = ['save', 'agosm.save']; - - // We can save this record, but check the create permission to see if we can return to make a new one. - if ($canDo->get('core.create')) { - $toolbarButtons[] = ['save2new', 'agosm.save2new']; - } - } - - // If checked out, we can still save - if ($canDo->get('core.create')) { - $toolbarButtons[] = ['save2copy', 'agosm.save2copy']; - } - - ToolbarHelper::saveGroup( - $toolbarButtons, - 'btn-success' - ); - - if (Associations::isEnabled() && ComponentHelper::isEnabled('com_associations')) { - ToolbarHelper::custom('agosm.editAssociations', 'contract', 'contract', 'JTOOLBAR_ASSOCIATIONS', false, false); - } - - ToolbarHelper::cancel('agosm.cancel', 'JTOOLBAR_CLOSE'); - } - - ToolbarHelper::divider(); - ToolbarHelper::help('', false, 'http://joomla.org'); - } -} diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foos/HtmlView.php b/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foos/HtmlView.php deleted file mode 100644 index d507369d..00000000 --- a/j4/pkg_agosms/src/administrator/components/com_agosms/src/View/Foos/HtmlView.php +++ /dev/null @@ -1,206 +0,0 @@ -items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->filterForm = $this->get('FilterForm'); - $this->activeFilters = $this->get('ActiveFilters'); - $this->state = $this->get('State'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) { - throw new GenericDataException(implode("\n", $errors), 500); - } - - // Preprocess the list of items to find ordering divisions. - // TODO: Complete the ordering stuff with nested sets - foreach ($this->items as &$item) { - $item->order_up = true; - $item->order_dn = true; - } - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') { - $this->addToolbar(); - $this->sidebar = \JHtmlSidebar::render(); - } else { - // In article associations modal we need to remove language filter if forcing a language. - // We also need to change the category filter to show show categories with All or the forced language. - if ($forcedLanguage = Factory::getApplication()->input->get('forcedLanguage', '', 'CMD')) { - // If the language is forced we can't allow to select the language, so transform the language selector filter into a hidden field. - $languageXml = new \SimpleXMLElement(''); - $this->filterForm->setField($languageXml, 'filter', true); - - // Also, unset the active language filter so the search tools is not open by default with this filter. - unset($this->activeFilters['language']); - - // One last changes needed is to change the category filter to just show categories with All language or with the forced language. - $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter'); - } - } - - parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @return void - * - * @since __BUMP_VERSION__ - */ - protected function addToolbar() - { - AgosmHelper::addSubmenu('agosms'); - $this->sidebar = \JHtmlSidebar::render(); - - $canDo = ContentHelper::getActions('com_agosms', 'category', $this->state->get('filter.category_id')); - $user = Factory::getUser(); - - // Get the toolbar object instance - $toolbar = Toolbar::getInstance('toolbar'); - - ToolbarHelper::title(Text::_('COM_AGOSMS_MANAGER_AGOSMS'), 'address agosm'); - - if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_agosms', 'core.create')) > 0) { - $toolbar->addNew('agosm.add'); - } - - if ($canDo->get('core.edit.state')) { - $dropdown = $toolbar->dropdownButton('status-group') - ->text('JTOOLBAR_CHANGE_STATUS') - ->toggleSplit(false) - ->icon('fa fa-ellipsis-h') - ->buttonClass('btn btn-action') - ->listCheck(true); - $childBar = $dropdown->getChildToolbar(); - $childBar->publish('agosms.publish')->listCheck(true); - $childBar->unpublish('agosms.unpublish')->listCheck(true); - - $childBar->standardButton('featured') - ->text('JFEATURE') - ->task('agosms.featured') - ->listCheck(true); - $childBar->standardButton('unfeatured') - ->text('JUNFEATURE') - ->task('agosms.unfeatured') - ->listCheck(true); - - $childBar->archive('agosms.archive')->listCheck(true); - - if ($user->authorise('core.admin')) { - $childBar->checkin('agosms.checkin')->listCheck(true); - } - - if ($this->state->get('filter.published') != -2) { - $childBar->trash('agosms.trash')->listCheck(true); - } - - if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) { - $childBar->delete('agosms.delete') - ->text('JTOOLBAR_EMPTY_TRASH') - ->message('JGLOBAL_CONFIRM_DELETE') - ->listCheck(true); - } - - // Add a batch button - if ($user->authorise('core.create', 'com_agosms') - && $user->authorise('core.edit', 'com_agosms') - && $user->authorise('core.edit.state', 'com_agosms')) { - $childBar->popupButton('batch') - ->text('JTOOLBAR_BATCH') - ->selector('collapseModal') - ->listCheck(true); - } - } - - if ($user->authorise('core.admin', 'com_agosms') || $user->authorise('core.options', 'com_agosms')) { - $toolbar->preferences('com_agosms'); - } - - ToolbarHelper::divider(); - ToolbarHelper::help('', false, 'http://joomla.org'); - - HTMLHelper::_('sidebar.setAction', 'index.php?option=com_agosms'); - } -} diff --git a/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php b/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php new file mode 100644 index 00000000..8f9ad63c --- /dev/null +++ b/j4/pkg_agosms/src/administrator/components/com_agosms/tmpl/agosms/emptystate.php @@ -0,0 +1,29 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +\defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Layout\LayoutHelper; + +$displayData = [ + 'textPrefix' => 'COM_AGOSMS', + 'formURL' => 'index.php?option=com_agosms', + 'helpURL' => 'https://github.com/astridx/pkg_agosms/blob/master/j4/pkg_agosms/README.md', + 'icon' => 'icon-copy', +]; + +$user = Factory::getApplication()->getIdentity(); + +if ($user->authorise('core.create', 'com_agosms') || count($user->getAuthorisedCategories('com_agosms', 'core.create')) > 0) +{ + $displayData['createURL'] = 'index.php?option=com_agosms&task=agosm.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData);