Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sector Nord AG: Agent Dashboard mandatory columns fix #547

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Kernel/Output/HTML/Dashboard/TicketGeneric.pm
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ sub Preferences {
# configure columns
my @ColumnsEnabled;
my @ColumnsAvailable;
my @ColumnsMandatory;
my @ColumnsAvailableNotEnabled;

# check for default settings
Expand All @@ -384,6 +385,16 @@ sub Preferences {
UserID => $Self->{UserID},
);

# set mandatory columns
@ColumnsMandatory = (
'TicketNumber',
);

if ($Self->{Config}->{IsProcessWidget}) {
push @ColumnsMandatory, 'DynamicField_' . $Self->{ProcessManagementProcessID};
push @ColumnsMandatory, 'DynamicField_' . $Self->{ProcessManagementActivityID};
}

# get JSON object
my $JSONObject = $Kernel::OM->Get('Kernel::System::JSON');

Expand Down Expand Up @@ -454,6 +465,7 @@ sub Preferences {
Columns => $JSONObject->Encode( Data => \%Columns ),
ColumnsEnabled => $JSONObject->Encode( Data => \@ColumnsEnabled ),
ColumnsAvailable => $JSONObject->Encode( Data => \@ColumnsAvailableNotEnabled ),
ColumnsMandatory => $JSONObject->Encode( Data => \@ColumnsMandatory ),
Translation => 1,
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
value="[% Data.Columns | html %]" />
<input type="hidden" class="ColumnsEnabledJSON" value="[% Data.ColumnsEnabled | html %]" />
<input type="hidden" class="ColumnsAvailableJSON" value="[% Data.ColumnsAvailable | html %]" />
<input type="hidden" class="ColumnsMandatoryJSON" value="[% Data.ColumnsMandatory | html %]" />

<label class="DontPrint">[% Translate(Data.Desc) | html %]:</label>
<div class="Field DontPrint LayoutGrid AllocationListContainer modal-col-container">
Expand Down
25 changes: 25 additions & 0 deletions var/httpd/htdocs/js/Core.Agent.Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,31 @@ Core.Agent.Dashboard = (function (TargetNS) {
InitContainer = Core.Config.Get('InitContainer' + ElementID),
ValidationErrors = false;

// Disallow saving of config if mandatory fields are not present
var DataMandatoryJSON = $ClickedElement.closest('form').find('input.ColumnsMandatoryJSON').val(),
AvailableFields = $ClickedElement.closest('form').find('ul.AvailableFields'),
DataMandatory,
MissingColumns = [];

if (DataMandatoryJSON) {
DataMandatory = Core.JSON.Parse(DataMandatoryJSON);
}

$.each(DataMandatory, function(Index, Field) {
if (AvailableFields.find('li[data-fieldname="' + Field.trim() + '"]').length > 0) {
var ColumnTitle = AvailableFields.find('li[data-fieldname="' + Field.trim() + '"]').attr('title');
MissingColumns.push(ColumnTitle);
}
});

if (MissingColumns.length > 0) {
Core.UI.Dialog.ShowAlert(
Core.Language.Translate('An Error Occurred'),
Core.Language.Translate('This field is required.') + ' ' + MissingColumns.join(', ') + "."
);
return false;
}

// check for elements to validate
$ClickedElement.closest('fieldset').find('.StatsSettingsBox').find('.TimeRelativeUnitView').each(function() {
var MaxXaxisAttributes = Core.Config.Get('StatsMaxXaxisAttributes') || 1000,
Expand Down
Loading