feat: Add TargetType form and migration for plan targets
- Implemented TargetType form for managing target details including name, type, priority, stages, estimated size, profile criteria, pain points, value proposition, and preferred channels. - Created migration scripts for adding type and priority columns to plan objectives and tasks. - Added migration for creating plan targets and plan target stages tables, including foreign key constraints. - Introduced stakeholder management with forms and views for creating, editing, and listing stakeholders. - Enhanced UI with read more functionality for long text descriptions and filtering options in plan tab tables.
This commit is contained in:
1 parent
8c8d7a6f95
commit
8696acd01c
52 files changed
+3178
-125
No files matched your search
+185
-1
@@ -4,9 +4,29 @@
|
||||
* - Plan form: editable, sortable rows (objectives, description items, allocation items), the selected
|
||||
* item type's description, and tab error markers. Started by Mautic.planOnLoad(), which Mautic calls after
|
||||
* it loads any page whose mauticContent is "plan", including pages loaded through Ajax.
|
||||
* - Task form (mauticContent "planTask", started by Mautic.planTaskOnLoad()): the selected type's
|
||||
* description and pictogram, next to the type dropdown.
|
||||
* - Settings > Configuration > Plan: adding and removing item types (delegated handlers,
|
||||
* because that page isn't a "plan" page).
|
||||
*/
|
||||
Mautic.planTaskOnLoad = function (container) {
|
||||
// The task form isn't a plan-collection; the type dropdown works the same way as in the plan form.
|
||||
mQuery(container).find('select.plan-item-type').each(function () {
|
||||
var $select = mQuery(this);
|
||||
|
||||
if ($select.data('planTaskInitialized')) {
|
||||
return;
|
||||
}
|
||||
$select.data('planTaskInitialized', true);
|
||||
|
||||
$select.on('change', function () {
|
||||
var $option = $select.find('option:selected');
|
||||
var $scope = $select.closest('form');
|
||||
$scope.find('.plan-item-type-help').first().text($option.attr('data-description') || '');
|
||||
$scope.find('.plan-item-type-icon').first().attr('class', 'plan-item-type-icon ' + ($option.attr('data-icon') || ''));
|
||||
});
|
||||
});
|
||||
};
|
||||
Mautic.planOnLoad = function (container) {
|
||||
mQuery(container).find('.plan-collection').each(function () {
|
||||
Mautic.planInitCollection(mQuery(this));
|
||||
@@ -14,6 +34,170 @@ Mautic.planOnLoad = function (container) {
|
||||
mQuery(container).find('.plan-tabs').each(function () {
|
||||
Mautic.planInitTabs(mQuery(this), mQuery(container));
|
||||
});
|
||||
// Detail page: the four tab tables (description items, objectives, allocation items, tasks).
|
||||
mQuery(container).find('table[data-plan-tab-table]').each(function () {
|
||||
Mautic.planInitTabTable(mQuery(this));
|
||||
});
|
||||
// Detail page: long description item texts, clamped to 10 lines with a read-more toggle.
|
||||
mQuery(container).find('.plan-read-more').each(function () {
|
||||
Mautic.planInitReadMore(mQuery(this));
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* A text clamped to a few lines with a "Read more" / "Show less" toggle. The clamping is done by CSS
|
||||
* (line-clamp, see the include template); a toggle appears only when the text really overflows, because
|
||||
* a button under a short text would only state the obvious.
|
||||
*
|
||||
* The overflow is measured when the tab pane is visible: a tab pane that is hidden on page load
|
||||
* (Mautic reopens the tab last used) has no layout, so its scrollHeight is 0. The wrapper is rechecked
|
||||
* on every tab activation until the measurement could run.
|
||||
*/
|
||||
Mautic.planInitReadMore = function ($wrapper) {
|
||||
if ($wrapper.data('planReadMoreInitialized')) {
|
||||
return;
|
||||
}
|
||||
$wrapper.data('planReadMoreInitialized', true);
|
||||
|
||||
var $text = $wrapper.find('.plan-read-more-text').first();
|
||||
var $toggle = $wrapper.find('.plan-read-more-toggle').first();
|
||||
var clampLines = 10;
|
||||
|
||||
var measure = function () {
|
||||
if (!$text[0] || !$wrapper.is(':visible')) {
|
||||
return false; // Still hidden: try again on the next tab activation.
|
||||
}
|
||||
|
||||
var lineHeight = parseFloat($text.css('line-height')) || 20;
|
||||
var clampHeight = clampLines * lineHeight;
|
||||
|
||||
if ($text[0].scrollHeight > clampHeight + 2) {
|
||||
$toggle.show();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
$toggle.on('click', function () {
|
||||
var open = 'false' === $toggle.attr('aria-expanded');
|
||||
$toggle.attr('aria-expanded', open ? 'true' : 'false');
|
||||
$text.css('-webkit-line-clamp', open ? 'none' : clampLines);
|
||||
// The texts come from the button's data attributes (rendered translated by Twig): the JS
|
||||
// translation catalog only holds core strings, not the plugin's.
|
||||
$toggle.html(
|
||||
(open ? $toggle.attr('data-less-text') : $toggle.attr('data-more-text')) +
|
||||
' <i class="ri-arrow-' + (open ? 'up' : 'down') + '-s-line"></i>'
|
||||
);
|
||||
});
|
||||
|
||||
if (!measure()) {
|
||||
// The pane holding this text is hidden: recheck each time a tab of this page is shown.
|
||||
mQuery(document).on('shown.bs.tab.plan-read-more', function () {
|
||||
if (measure()) {
|
||||
mQuery(document).off('shown.bs.tab.plan-read-more');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A plan detail page tab table: one filter box filtering every column (case-insensitive substring),
|
||||
* and every column header sorting the rows asc/desc on click. Filtering and sorting are done on the
|
||||
* client, instantly: these tables hold one plan's items, never many.
|
||||
*
|
||||
* Rows keep their order attribute, so the drag handles and the tree indentation of tasks stay right.
|
||||
* Sorting the tree by another column can interleave a sub-task before its parent; the depth marker
|
||||
* stays attached to its own row, so it just indents wherever it lands.
|
||||
*/
|
||||
Mautic.planInitTabTable = function ($table) {
|
||||
if ($table.data('planTabTableInitialized')) {
|
||||
return;
|
||||
}
|
||||
$table.data('planTabTableInitialized', true);
|
||||
|
||||
var $panes = $table.closest('.tab-pane');
|
||||
var $filterBox = $panes.find('.plan-tab-table-filter').first();
|
||||
var $input = $filterBox.find('.plan-tab-table-filter-input');
|
||||
var $noMatch = $panes.find('.plan-tab-table-nomatch').first();
|
||||
var $rows = $table.find('tbody tr');
|
||||
|
||||
var apply = function () {
|
||||
var needle = mQuery.trim($input.val() || '').toLowerCase();
|
||||
var visible = 0;
|
||||
|
||||
$rows.each(function () {
|
||||
var text = mQuery(this).text().toLowerCase().replace(/\s+/g, ' ');
|
||||
var show = '' === needle || -1 !== text.indexOf(needle);
|
||||
mQuery(this).toggleClass('hide', !show);
|
||||
if (show) {
|
||||
visible++;
|
||||
}
|
||||
});
|
||||
|
||||
$noMatch.toggleClass('hide', visible > 0);
|
||||
};
|
||||
|
||||
$input.on('input', apply);
|
||||
$input.on('change', apply);
|
||||
|
||||
// Click-to-sort: first click ascending, then toggling. The footer row (allocation total) stays put.
|
||||
$table.find('thead th').each(function (index) {
|
||||
var $th = mQuery(this);
|
||||
|
||||
$th.css('cursor', 'pointer').attr('title', $table.attr('data-sort-hint') || '');
|
||||
$th.on('click', function () {
|
||||
var direction = $th.hasClass('plan-sorted-asc') ? -1 : 1;
|
||||
var cells = [];
|
||||
|
||||
$rows.each(function () {
|
||||
cells.push({
|
||||
text: mQuery(this).find('td').eq(index).text().replace(/\s+/g, ' ').trim(),
|
||||
$row: mQuery(this)
|
||||
});
|
||||
});
|
||||
|
||||
cells.sort(function (a, b) {
|
||||
var va = a.text.toLowerCase();
|
||||
var vb = b.text.toLowerCase();
|
||||
var result;
|
||||
|
||||
// Amounts like "18,500.00 EUR" and numbers sort numerically when both hold one.
|
||||
var na = Mautic.planParseNumber(va);
|
||||
var nb = Mautic.planParseNumber(vb);
|
||||
if (null !== na && null !== nb) {
|
||||
result = na - nb;
|
||||
} else {
|
||||
result = va < vb ? -1 : (va > vb ? 1 : 0);
|
||||
}
|
||||
|
||||
return result * direction;
|
||||
});
|
||||
|
||||
mQuery.each(cells, function () {
|
||||
this.$row.appendTo($table.find('tbody'));
|
||||
});
|
||||
|
||||
$table.find('thead th').removeClass('plan-sorted-asc plan-sorted-desc');
|
||||
$th.addClass(direction > 0 ? 'plan-sorted-asc' : 'plan-sorted-desc');
|
||||
$rows = $table.find('tbody tr');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* A cell "18,500.00 EUR" or "12" as a number for the tab table sort, or null when it holds no number
|
||||
* (text, dates as words). The last number in the cell wins, so a name like "Q1 2027" sorts by 2027.
|
||||
*/
|
||||
Mautic.planParseNumber = function (text) {
|
||||
var match = String(text).match(/-?\d[\d,\s]*\.?\d*/g);
|
||||
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var value = parseFloat(match[match.length - 1].replace(/[\s,]/g, ''));
|
||||
|
||||
return isNaN(value) ? null : value;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -160,7 +344,7 @@ Mautic.planInitCollection = function ($editor) {
|
||||
});
|
||||
|
||||
// Typed items (description, allocation): show the selected type's description under the dropdown, and
|
||||
// its pictogram next to it.
|
||||
// its pictogram next to it. Works within a plan-collection row.
|
||||
$editor.on('change', 'select.plan-item-type', function () {
|
||||
var $option = mQuery(this).find('option:selected');
|
||||
var $row = mQuery(this).closest('.plan-collection-row');
|
||||
|
||||
Reference in new issue
Block a user