67
# Fetch the edited row if we are editing one
69
if ($editid and ($editid ne 'undefined')) {
70
$rowEdit = $model->row($editid);
73
# Fetch the data to be displayed in setters, if we are editing a row
74
# we should show the contents of the current fields. If we are
75
# adding a new row, the fields are empty except for a preset values
76
# adding where preset contents must be shown
77
my @formData = @tableHead;
79
@formData = @{$rowEdit->elements()};
80
} elsif ( ((keys %presetParams) > 0)
81
and $action eq 'presetUpdate') {
82
# The preset is not empty
83
@formData = values(%presetParams);
85
71
# If the action is a preset update, choose for an edition or an
86
72
# addition whether the editid is set or not
87
73
if ( $action eq 'presetUpdate' ) {
92
78
my $pageSize = $model->pageSize();
83
my $checkAllProperty = $model->checkAllProperty();
84
if ($checkAllProperty) {
85
%checkAllControls = map {
87
my $id = $tableName . '_'. $field . '_CheckAll';
89
} @{ $checkAllProperty } ;
97
93
crumbs => $model->viewCustomizer()->HTMLTitle()
100
% if ( $model->pageTitle() ) {
101
% my $viewCustomizer = $model->viewCustomizer();
102
% my $msg = $viewCustomizer ? $viewCustomizer->permanentMessage() : undef;
103
% my $type = $viewCustomizer ? $viewCustomizer->permanentMessageType() : undef;
110
% if ( $model->message() ) {
112
msg => $model->popMessage(),
113
class => $model->messageClass()
119
% my $help = $model->help();
125
% my $disabledModuleWarning = $model->disabledModuleWarning();
126
% if ($disabledModuleWarning) {
127
<div class="warning">
128
<% $disabledModuleWarning %>
132
% if ( $action ne 'changeAdd' and $action ne 'changeEdit' )
134
% if ( $model->printableModelName() )
137
title => $model->headTitle()
140
% if ($changeView and exists $actions->{'add'})
142
<a href='#' class='addNew'
145
$model->changeViewJS( changeType => "changeAdd",
146
editId => "undefined",
149
%>;return false"><% __('Add new') %></a>
96
% my $showEditForm = $action eq any('changeAdd', 'changeEdit', 'clone');
97
% if (not $showEditForm) {
98
% if ( $model->printableModelName() ) {
100
title => $model->headTitle()
102
<& SELF:messagesAndHelp, model => $model &>
104
% unless ((defined $onlyCustomActions) and $onlyCustomActions) {
106
<& SELF:tableActionLinks,
108
addAction => (exists $actions->{'add'}),
153
114
<span id="<% 'creatingForm_' . $tableName %>"></span>
156
% if ( $action eq 'changeAdd' or $action eq 'changeEdit' ) {
157
% if ( $action eq 'changeAdd' ) {
158
% my $addingStr = __x('Adding a new {row}', row => $printableRowName);
159
<& PARENT:title, title => $addingStr &>
160
% } elsif ( $action eq 'changeEdit' ) {
163
% my $editingStr = __x('Editing {row}', row => $printableRowName);
164
<& PARENT:title, title => $editingStr &>
118
% unless ((defined $onlyCustomActions) and $onlyCustomActions) {
119
% if ($showEditForm) {
120
<& SELF:editFormTitle,
122
printableRowName => $printableRowName,
124
<& SELF:messagesAndHelp, model => $model &>
125
<& SELF:editFormPopulated,
129
presetParams => \%presetParams
168
modelName => $tableName,
169
formData => \@formData,
170
sections => $model->sections(),
173
% my $customizer = $formData[0]->model()->viewCustomizer();
176
<% $customizer->onChangeActionsJS() %>
182
% if (@ids or length($filter) > 0)
184
% if ( $action eq 'changeAdd' or $action eq 'changeEdit' )
135
% if (@ids or length($filter) > 0) {
137
% unless ((defined $onlyCustomActions) and $onlyCustomActions) {
138
% if ( $action eq 'changeAdd' or $action eq 'changeEdit' ) {
188
141
$printableTableName
147
tableName => $tableName,
193
<table class="bDataTable">
196
<form action="javascript:void(0)">
197
% my $filterId = $tableName . '_filterLoading';
203
$tableName . "_filter"
211
value="<% __('Search') %>"
213
onClick="setLoading('<%
217
$model->changeViewJS( changeType => "changeList",
218
editId => 'undefined',
233
153
$model->table()->{'class'}
236
<& SELF:tableHead, tableHead => \@tableHead &>
156
<& SELF:tableHead, tableHead => \@tableHead,
157
actions => ((defined $withoutActions) ? not $withoutActions: 1),
160
checkAllControls => \%checkAllControls,
255
180
$row = $model->row($ids[$idx]);
263
% foreach my $td (@{$row->elements()})
265
% next unless ($td->HTMLViewer());
183
<tr class='border' id="<% $row->id() %>">
185
% foreach my $td (@{$row->elements()}) {
187
next unless ($td->HTMLViewer());
189
my @viewerParams = (data => $td);
190
if ($td->isa('EBox::Types::Boolean')) {
191
my $checkAllId = $checkAllControls{$td->fieldName()};
192
push @viewerParams, (checkAllId => $checkAllId);
266
195
<td class='tcenter'>
268
197
$td->HTMLViewer(),
203
% unless ((defined $withoutActions) and $withoutActions) {
275
204
<& SELF:actionCell, model => $model,
276
205
actions => $actions,
321
% if ( $action eq 'changeEdit' and $editid ) {
251
% unless ((defined $onlyCustomActions) and $onlyCustomActions) {
252
% if ( $action eq 'changeEdit' and $editid ) {
322
253
<script>highlightRow('<% $editid %>', 1);</script>
325
256
% # End body method
265
<table class="bDataTable">
269
tableName => $tableName,
285
my $filterId = $tableName . '_filterLoading';
287
<form action="javascript:void(0)">
294
$tableName . "_filter"
302
value="<% __('Search') %>"
304
onClick="setLoading('<%
308
$model->changeViewJS( changeType => "changeList",
309
editId => 'undefined',
322
<%method editFormTitle>
328
% if ( $action eq 'changeAdd' ) {
329
% $formTitle = __x('Adding a new {row}', row => $printableRowName);
330
% } elsif ( $action eq 'changeEdit' ) {
332
% $formTitle = __x('Editing {row}', row => $printableRowName);
333
% } elsif ($action eq 'clone') {
335
% $formTitle = __x('Cloning {row}', row => $printableRowName);
337
<& PARENT:title, title => $formTitle &>
340
<%method editFormPopulated>
346
@customizerParams => ()
349
my $tableName = $model->table()->{'tableName'};
350
my @tableHead = @{$model->table()->{'tableDescription'}};
351
if ($action eq 'add') {
352
foreach my $element (@tableHead) {
353
$element->setValue($element->defaultValue());
357
# Fetch the data to be displayed in setters, if we are editing a row
358
# we should show the contents of the current fields. If we are
359
# adding a new row, the fields are empty except for a preset values
360
# adding where preset contents must be shown
363
if ($editid and ($editid ne 'undefined')) {
364
my $fetchRow = $model->row($editid);
365
@formData = @{$fetchRow->elements()};
366
if ($action eq 'clone') {
367
# unique fields should not be cloned
368
my @uniqFields = grep { $_->unique() } @tableHead;
369
foreach my $uniqField (@uniqFields) {
370
foreach my $clonedField (@formData) {
371
if ($uniqField->fieldName() eq $clonedField->fieldName()) {
372
$clonedField = $uniqField;
378
} elsif ( ((keys %presetParams) > 0)
379
and $action eq 'presetUpdate') {
380
# The preset is not empty
381
@formData = values(%presetParams);
383
@formData = @tableHead;
387
modelName => $tableName,
388
formData => \@formData,
389
sections => $model->sections(),
392
% my $customizer = $formData[0]->model()->viewCustomizer(@customizerParams);
395
<% $customizer->onChangeActionsJS() %>
345
417
my $filter = $requestArgs->{filter};
346
418
my $page = $requestArgs->{page};
347
419
my $tpages = $requestArgs->{tpages};
421
my $modelName = $model->modelName();
348
422
my $changeView = $model->action('changeView');
423
my $onlyCustomActions = $model->table()->{'onlyCustomActions'};
424
my $withoutActions = $model->table()->{'withoutActions'};
350
427
if ( $action eq 'presetUpdate' ) {
351
428
$action = 'changeAdd' if ( not $editid );
352
429
$action = 'changeEdit' if ( $editid );
430
} elsif ($action eq 'clone') {
431
$action = 'changeAdd';
435
% unless ((defined $withoutActions) and $withoutActions) {
356
437
<td id="applyChanges">
358
<td id="<% 'buttons_' . $model->modelName() %>">
359
% if ( $action eq 'changeAdd' )
439
<td id="<% 'buttons_' . $modelName %>">
440
% unless ((defined $onlyCustomActions) and $onlyCustomActions)
442
% if ( $action eq 'changeAdd' )
444
% # extra input for cloneId
447
name => $modelName . '_cloneId',
448
id => $modelName . '_cloneId',
361
452
<& /input/submit.mas,
362
453
class => 'inputButton',
363
454
type => 'submit',
365
456
value => __('Add'),
367
onclick => $model->addNewRowJS($page) . '; return false'
458
onclick => $model->addNewRowJS($page, cloneId => $cloneId) . '; return false'
370
% elsif ($action eq 'changeEdit')
461
% elsif ($action eq 'changeEdit')
372
463
<& /input/submit.mas,
373
464
class => 'inputButton',
374
465
type => 'submit',
424
521
$th->printableName()
525
% my $spaceAdded = 0;
526
% my $fieldName = $th->fieldName();
527
% if ($th->isa('EBox::Types::Boolean')) {
528
% my $checkAllId = $checkAllControls{$fieldName};
530
<& SELF:checkAllControl,
532
fieldName => $fieldName,
539
% unless ($spaceAdded) {
429
547
<th class='thOptions'>
559
<%method checkAllControl>
567
my $tableName = $model->name();
569
$divId =~ s/_CheckAll$/_div_CheckAll/;
572
my $checkAllJS= $model->changeViewJS( changeType => "checkboxSetAll",
573
editId => $fieldName,
576
my $uncheckAllJS= $model->changeViewJS( changeType => "checkboxUnsetAll",
577
editId => $fieldName,
580
my $onChangeJS =qq|if (this.checked) {$checkAllJS } else {$uncheckAllJS;} |;
581
my @htmlAttrs = (onchange => $onChangeJS);
582
push @htmlAttrs, (id => $id);
583
if ( $model->checkAllControlValue($fieldName)) {
584
push @htmlAttrs, ('checked' => 'checked');
588
<div id=<% $divId %> >
589
<input type='checkbox'
590
<& /htmlAttributes.mas, @htmlAttrs &>
595
<%method tableActionLinks>
602
my $actionLinksAdded = 0;
603
my $tableName = $model->name();
604
my $checkAll = $model->checkAllProperty();
607
% $actionLinksAdded = 1;
608
<a href='#' class='addNew'
611
$model->changeViewJS( changeType => "changeAdd",
612
editId => "undefined",
615
%>;return false"><% __('Add new') %></a>
618
% if ($actionLinksAdded) {
437
624
<%method actionCell>
439
626
Print the action cell for the row
466
653
my $rowReadOnly = $row->readOnly() ;
468
655
my $disabled = '';
470
my $edit_msg = __('Edit');
471
my $delete = 'delete';
472
my $delete_msg = __('Delete');
656
my ($edit, $edit_msg);
657
my ($delete, $delete_msg);
658
my ($clone, $clone_msg);
659
if (not $rowReadOnly) {
661
$edit_msg = __('Edit');
663
$delete_msg = __('Delete');
665
$clone_msg = __('Clone');
474
667
$disabled = 'disabled';
475
668
$edit = 'edit-inactive';
476
669
$delete = 'delete-inactive';
477
670
$edit_msg = __('Read-only row: edit disabled');
478
671
$delete_msg = __('Read-only row: delete disabled');
672
$clone = 'clone-inactive';
673
$clone_msg = __('Read-only row: clone disabled');
675
my $onlyCustomActions = $model->table()->{'onlyCustomActions'};
481
677
<& /ajax/customActions.mas, model => $model, id => $row->{id}, type => 'image' &>
679
% unless ((defined $onlyCustomActions) and $onlyCustomActions)
483
681
% if ($actions->{'del'})
485
683
<input class='inputButton'