refactor(program): move item types out of Settings > Configuration
Relocate the item type lists (insights, allocations, objectives, tasks, stakeholders, audience values) from the Configuration tab to a dedicated "Item types" page under Programs, served by ItemTypesController at /program-item-types and guarded by the new program:itemtypes:view permission. The Program settings tab in Configuration now only holds the general settings (currency, stakeholder phone region, audience attribute toggles), so ConfigSubscriber no longer needs the item repositories; the in-use type protection moved to ItemTypeInUseGuard.
This commit is contained in:
1 parent
71ff11390b
commit
687d33d30c
14 files changed
+444
-219
No files matched your search
@@ -16,9 +16,9 @@ This repository holds only the plugin source. The bundle files are at the reposi
|
||||
|
||||
3. In Mautic, go to **Settings > Plugins**, open **Program** and publish it.
|
||||
|
||||
Initiatives are listed under **Programs > Initiatives** in the main menu (URL `/s/programs`), tasks under **Programs > Tasks** (URL `/s/program-tasks`), the stakeholder directory under **Programs > Stakeholders** (URL `/s/program-stakeholders`), and the audience directory under **Programs > Audiences** (URL `/s/program-audiences`). **Programs > UTM Taxonomies** (URL `/s/program-utm-taxonomies`) is a placeholder for a coming feature. Users who aren't administrators need a role with the **Program Permissions** set in **Settings > Roles**.
|
||||
Initiatives are listed under **Programs > Initiatives** in the main menu (URL `/s/programs`), tasks under **Programs > Tasks** (URL `/s/program-tasks`), the stakeholder directory under **Programs > Stakeholders** (URL `/s/program-stakeholders`), and the audience directory under **Programs > Audiences** (URL `/s/program-audiences`). The item type lists are edited under **Programs > Item types** (URL `/s/program-item-types`), below **UTM Taxonomies** (URL `/s/program-utm-taxonomies`, a placeholder for a coming feature). Users who aren't administrators need a role with the **Program Permissions** set in **Settings > Roles**.
|
||||
|
||||
Before using the items of an initiative's **Insights**, **Objectives**, **Allocations** and **Tasks** tabs, an administrator sets up their types in **Settings > Configuration > Program Settings**.
|
||||
Before using the items of an initiative's **Insights**, **Objectives**, **Allocations** and **Tasks** tabs, set up their types under **Programs > Item types** (`program:itemtypes:view` to see the page, `program:itemtypes:edit` to save it).
|
||||
|
||||
## Development
|
||||
|
||||
@@ -68,6 +68,7 @@ The plugin uses the IntegrationsBundle conventions:
|
||||
- `Resources/views/Initiative/_task_table.html.twig`: the initiative's tasks in the Tasks tab. It has the harmonized tab columns (pictogram, Type, Name with kind badge for milestones and phases, Description, Start date, End date, Status — no ID), one row per task, no tree: a phase's or milestone's badge marks it in the name column. On the detail page it has an **Add task** button, links to each task and the filter/sort of the other tabs. On the initiative form it is read-only (no links, no filter), so that following a link doesn't drop unsaved changes.
|
||||
- `Controller/TaskController.php` and `Resources/views/Task/`: the task list, and the create/edit form (**Programs > Tasks**). `new?initiative=ID` preselects the initiative. After Save or Cancel, the user goes back to where the form was opened from. Opened from **Programs > Tasks**, that's the task list. Opened from an initiative's Tasks tab, whose links carry `returnTo=initiative`, that's the initiative (its new initiative, if the task was moved). The origin is stored in the session when the form is opened, because the form posts without the query string.
|
||||
- `Controller/UtmTaxonomyController.php` and `Resources/views/UtmTaxonomy/`: the placeholder page for the coming UTM Taxonomies feature.
|
||||
- `Controller/ItemTypesController.php` and `Resources/views/ItemTypes/form.html.twig`: the Item types page (**Programs > Item types**), below UTM Taxonomies in the menu. The type lists that used to be sections of **Settings > Configuration > Program Settings** (insights, allocation, objective, task, stakeholder types and the audience decision roles and tones) are edited here. `Form/Type/ItemTypesType.php` builds the lists, `Service/ItemTypeInUseGuard.php` refuses to remove a type that items still use, and the page saves through core's `Configurator` exactly like the Settings pages do: merge into `config/local.php`, write, refresh the config cache. **Settings > Configuration > Program Settings** keeps only the plugin's general settings: the currency, the stakeholder phone region and the audience attribute toggles.
|
||||
- `Assets/js/program.js`: on the form, the objectives editor (add, remove, drag-and-drop ordering), and after a failed save, marking the tabs that contain errors with an icon and opening the first one. Started by `Mautic.programOnLoad()`.
|
||||
|
||||
The initiative's tab panes deliberately have no Bootstrap `fade` class. Core reopens the last tab used on a page (`12.tabs.js`), and the plugin opens the tab with an error after a failed save. With `fade`, those two `tab('show')` calls overlapped within the 150 ms transition and left two panes visible at once, so the Tasks tab also showed the objectives.
|
||||
@@ -137,15 +138,15 @@ Behaviour to know about:
|
||||
- An **objective** (`Entity/InitiativeObjective.php`) has a type too (with its pictogram), a title, a priority (a whole number from 1, the most important, to 99), a description and the achieved flag. The initiative's Objectives tab lists them by priority; ties keep the manual order. The priority is required.
|
||||
- A **task** (`Entity/Task.php`) has a type too (with its pictogram): see *The Task object* below.
|
||||
- Description items, allocation items and objectives are edited inside the initiative form, like objectives: add, remove, drag to reorder. They're saved and deleted with the initiative. Tasks are edited on their own form, where the type's pictogram and description appear around the type dropdown.
|
||||
- An administrator sets up each kind's types in **Settings > Configuration > Program Settings**, in several sections. Each type has a name and a description for each language installed in Mautic, and the default language (the `locale` parameter) requires a name. Each type also has a pictogram. Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown.
|
||||
- Each kind's types are set up on the **Item types** page (**Programs > Item types**), in several sections. Each type has a name and a description for each language installed in Mautic, and the default language (the `locale` parameter) requires a name. Each type also has a pictogram (none for the audience decision roles and tones). Users see their own language, or the default language when theirs is empty. The order of the types is the order of the dropdown.
|
||||
- The types are stored in `config/local.php`, in the `program_description_item_types`, `program_allocation_item_types`, `program_objective_types`, `program_task_types` and `program_stakeholder_types` parameters. Read them with `Service/ItemTypeProvider.php`, passing the kind (`description`, `allocation`, `objective`, `task` or `stakeholder`). In templates, use the Twig functions `program_item_type_name(kind, key)`, `program_item_type_description(kind, key)` and `program_item_type_icon(kind, key)`, plus `program_currency()` and `program_money(amount)` (`Twig/ProgramExtension.php`).
|
||||
- **Every item type has a pictogram**, chosen by the administrator from a list of Remix Icons that Mautic ships (`Service/Pictograms.php`, each checked against Mautic 7's icon stylesheet), with a live preview. It's stored as `icon` in the type. On the initiative form and the task form it appears next to the type dropdown when a type is chosen.
|
||||
- **The four item tabs of an initiative's detail page are harmonized** (`Resources/views/Initiative/details.html.twig`, `_task_table.html.twig`, `_tab_table_filter.html.twig`): every column starts with the pictogram (its header stays empty — no "Pictogram" label), then Type, Name, Description, and the kind's other fields; objectives show their Priority after Description, and tasks end with Status. The initiative's Tasks tab doesn't show task IDs (`data-task-id` still carries them). Each tab has one filter box that matches every column, and every column header sorts the rows asc/desc on click (`Mautic.programInitTabTable` in `Assets/js/program.js`, client-side). The objective's achieved flag is the Status column of its table.
|
||||
- A description item's long description is **clamped to 10 lines** in the Insights tab, with a *Read more* / *Show less* toggle (`_description_read_more.html.twig`, `Mautic.programInitReadMore`). The toggle appears only when the text really overflows: the pane is hidden on page load, so the measurement waits for the tab to be shown.
|
||||
- Each type has a hidden key, generated when it's created and never changed. Items store that key, so renaming a type renames it everywhere.
|
||||
- A type that items use can't be removed: the configuration isn't saved, and the error lists the types and how many items use them (`EventListener/ConfigSubscriber.php`, on `CONFIG_PRE_SAVE`).
|
||||
- A type that items use can't be removed: the lists aren't saved, and the error lists the types and how many items use them (`Service/ItemTypeInUseGuard.php`, called by `ItemTypesController` before saving the page).
|
||||
- On the initiative form, the selected type's description is shown under the type dropdown. When no types are set up, the tab says where to set them up.
|
||||
- Files: `Form/Type/ConfigType.php`, `ItemTypeConfigType.php`, `InitiativeDescriptionItemType.php`, `InitiativeAllocationItemType.php` and `Resources/views/FormTheme/Config/_config_programconfig_widget.html.twig`. Adding and removing types is handled in `Assets/js/program.js`.
|
||||
- Files: `Form/Type/ItemTypesType.php`, `ItemTypeConfigType.php`, `InitiativeDescriptionItemType.php`, `InitiativeAllocationItemType.php`, `Controller/ItemTypesController.php` and `Resources/views/ItemTypes/form.html.twig` (the page), and `Form/Type/ConfigType.php` with `Resources/views/FormTheme/Config/_config_programconfig_widget.html.twig` (the general settings that stayed in **Settings > Configuration**). Adding and removing types is handled in `Assets/js/program.js`.
|
||||
|
||||
### Cost totals
|
||||
|
||||
|
||||
Reference in new issue
Block a user