Skip to content

Commit

Permalink
overlooked general history (for whole table, not a single dataset):
Browse files Browse the repository at this point in the history
now old history is present when table history is opened and new more functional history on dataset specific history
+ bringing back search
+ marker for current dataset in dataset specific mode
+ added css
+ outsourced js
  • Loading branch information
Peter Schulze committed Jun 11, 2024
1 parent 28118db commit e6eda59
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 139 deletions.
14 changes: 14 additions & 0 deletions plugins/manager/assets/history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

$(document).on('rex:ready', function (event, container) {
container.find('#rex-yform-history-modal').on('shown.bs.modal', function () {
// init tooltips
container.find('[data-toggle="tooltip"]').tooltip({
html: true
});

// history restore confirm dialog
$("#yform-manager-history-restore").on("click", function() {
return confirm($(this).attr('data-confirm-text'));
});
});
});
121 changes: 121 additions & 0 deletions plugins/manager/assets/manager.css
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,124 @@ body.rex-theme-dark .yform-be-relation-wrapper > div {
background: #1a3332
}
}

#rex-yform-history-modal.in {
display: flex !important;
}

#rex-yform-history-modal header.panel-heading:not(:first-of-type) {
margin-top: 3px;
}

#rex-yform-history-modal header.panel-heading .panel-title i {
display: inline-block;
width: 25px;
}

#rex-yform-history-modal header + .panel-collapse {
padding-top: 5px;
}

.history-list tr.current-dataset-row {
background-color: #a0e4c1;
}

.history-list .current-dataset-cell {
text-align: center;
}

.history-list .current-dataset-hint {
color: #5bb585;
font-style: italic;
}

.history-diff-table tbody td {
line-height: 1.5
}

.history-diff-table ins,
.history-diff-table .diff {
padding: 1px 4px;
border-radius: 3px;
}

.history-diff-table del {
color: #d68787;
}

.history-diff-table ins {
background-color: #a6e1a6;
text-decoration: none;
}

.history-diff-table .diff {
background-color: #c6daff;
}

.history-diff-table thead th:first-child {
padding-left: 10px;
}

.history-diff-table tbody th:first-child {
padding-left: 45px;
position: relative;
}

.history-diff-table tbody th:first-child > i,
.history-diff-table tbody th:first-child > span {
display: flex;
background-color: #F5F5F5;
width: 35px;
text-align: left;
position: absolute;
left: 0;
top: 1px;
bottom: 1px;
justify-content: center;
padding-top: 12px;
color: #000;
}

/* special for numbers */
.history-diff-table tbody th:first-child > i.rex-icon.fa-1:before {
content: '123';
}

.history-diff-table tbody th:first-child > span:before {
content: '';
display: block;
width: 23px;
height: 14px;
border: 1px solid #000;
border-radius: 3px;
}

.history-diff-table tbody th:first-child > span:after {
content: 'abc';
font-size: 8px;
position: absolute;
top: 15px;
left: 9px;
font-weight: bold;
}

#collapse-history-table-added .history-diff-table tbody th:first-child {
color: #088808;
}

#collapse-history-table-removed .history-diff-table tbody th:first-child {
color: #e30d0d;
}

#collapse-history-table-added .history-diff-table tbody td em,
#collapse-history-table-removed .history-diff-table tbody td em {
color: #AAA;
}

@media (min-width: 768px) {
#rex-yform-history-modal.in .modal-dialog {
max-width: calc(100% - 40px);
width: auto;
display: inline-block;
}
}
1 change: 1 addition & 0 deletions plugins/manager/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
rex_view::addJsFile($this->getAssetsUrl('relations.js'));
rex_view::addCssFile($this->getAssetsUrl('manager.css'));
rex_view::addJsFile($this->getAssetsUrl('widget.js'));
rex_view::addJsFile($this->getAssetsUrl('history.js'));

if (!rex::getUser()->isAdmin()) {
$page = $this->getProperty('page');
Expand Down
10 changes: 2 additions & 8 deletions plugins/manager/fragments/yform/manager/history.diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

// count diffs
if(!$currentDataset->hasValue($field->getName())) {
$change = 'deleted';
$change = 'removed';
} elseif('' . $historyValue !== '' . $currentValue) {
$change = 'changed';
}
Expand Down Expand Up @@ -188,17 +188,11 @@
$content .= '
</div>
<div class="modal-footer">
<a href="index.php?page=yform/manager/data_edit?' . $restoreUrl . '" class="btn btn-warning" onclick="return confirm(\'' . rex_i18n::msg('yform_history_restore_confirm') . '\')">' .
<a href="index.php?page=yform/manager/data_edit?' . $restoreUrl . '" class="btn btn-warning" id="yform-manager-history-restore" data-confirm-text="' . rex_i18n::msg('yform_history_restore_confirm') . '">' .
rex_i18n::msg('yform_history_restore_this') .
'</a>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<script>
// init bootstrap tooltips
$(".modal#rex-yform-history-modal [data-toggle=\"tooltip\"]").tooltip({
html: true
})
</script>
';

echo $content;
Expand Down
1 change: 1 addition & 0 deletions plugins/manager/lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ yform_history_diff_added = neu
yform_history_diff_removed = entfernt
yform_history_diff_not_yet_existing = noch nicht vorhanden
yform_history_diff_no_longer_existing = nicht mehr vorhanden
yform_history_is_current_dataset = aktuelle Version des Datensatzes

yform_manager_show_form_notation = Formular-Code

Expand Down
1 change: 1 addition & 0 deletions plugins/manager/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ yform_history_diff_added = added
yform_history_diff_removed = removed
yform_history_diff_not_yet_existing = not yet existing
yform_history_diff_no_longer_existing = no longer existing
yform_history_is_current_dataset = current version of the record

yform_manager_show_form_notation = Form code

Expand Down
1 change: 1 addition & 0 deletions plugins/manager/lang/es_es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ yform_history_diff_added = nuevo
yform_history_diff_removed = eliminado
yform_history_diff_not_yet_existing = aún no disponible
yform_history_diff_no_longer_existing = ya no está disponible
yform_history_is_current_dataset = versión actual del registro.

yform_manager_show_form_notation = Código del formulario

Expand Down
1 change: 1 addition & 0 deletions plugins/manager/lang/sv_se.lang
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ yform_history_diff_added = Tillagd
yform_history_diff_removed = Borttagen
yform_history_diff_not_yet_existing = Ännu Inte Existerande
yform_history_diff_no_longer_existing = Inte Längre Existerande
yform_history_is_current_dataset = aktuella versionen av datasatsen

yform_manager_show_form_notation = Formularkod

Expand Down
2 changes: 1 addition & 1 deletion plugins/manager/lib/yform/manager/dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ private static function tableToModel(string $table): string
/**
* @internal
*/
protected static function modelToTable(): string
final protected static function modelToTable(): string
{
$class = static::class;

Expand Down
2 changes: 1 addition & 1 deletion plugins/manager/lib/yform_history_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class rex_yform_history_helper

/**
* detect diffs in 2 strings.
* @return array<string|array<string>>
* @return array<string|array>
* @author Peter Schulze | p.schulze[at]bitshifters.de
* @created 17.04.2024
* @copyright https://github.com/paulgb/simplediff | Paul Butler (paulgb)
Expand Down
Loading

0 comments on commit e6eda59

Please sign in to comment.