1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

privacy policy: fixed admin view after update + display last update date

This commit is contained in:
Sylvain 2019-04-23 12:58:01 +02:00
parent d0f0a293f3
commit c0c9b2a980
9 changed files with 28 additions and 6 deletions

View File

@ -12,8 +12,8 @@
*/ */
'use strict'; 'use strict';
Application.Controllers.controller('SettingsController', ['$scope', '$uibModal', 'Setting', 'growl', 'settingsPromise', 'privacyDraftsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t', Application.Controllers.controller('SettingsController', ['$scope', '$filter', '$uibModal', 'Setting', 'growl', 'settingsPromise', 'privacyDraftsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t',
function ($scope, $uibModal, Setting, growl, settingsPromise, privacyDraftsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) { function ($scope, $filter, $uibModal, Setting, growl, settingsPromise, privacyDraftsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) {
/* PUBLIC SCOPE */ /* PUBLIC SCOPE */
// timepickers steps configuration // timepickers steps configuration
@ -191,11 +191,16 @@ Application.Controllers.controller('SettingsController', ['$scope', '$uibModal',
// reset history // reset history
$scope.privacyDraftsHistory = []; $scope.privacyDraftsHistory = [];
data.setting.history.forEach(function (draft) { data.setting.history.forEach(function (draft) {
$scope.privacyDraftsHistory.push({ id: draft.id, name: _t('settings.privacy.draft_from_USER_DATE', { USER: draft.user, DATE: draft.created_at }), content: draft.value }); $scope.privacyDraftsHistory.push({ id: draft.id, name: _t('settings.privacy.draft_from_USER_DATE', { USER: draft.user.name, DATE: draft.created_at }), content: draft.value });
}); });
if (type === 'privacy_draft') { if (type === 'privacy_draft') {
// FIXME const orderedHistory = $filter('orderBy')(data.setting.history, 'created_at');
$scope.privacyPolicy.version = data.setting.history[data.setting.history.length - 1].id; const last = orderedHistory[orderedHistory.length - 1];
if (last) {
$scope.privacyPolicy.version = last.id;
}
} else {
$scope.privacyPolicy.version = null;
} }
}) })
}); });

View File

@ -420,6 +420,10 @@
} }
.last-update {
text-align: right;
margin-bottom: 2em;
}
} }

View File

@ -9,6 +9,10 @@
<div class="row padder"> <div class="row padder">
<div class="col-sm-offset-1 col-md-offset-3 col-sm-7 col-md-5 col-lg-4 m-b-lg"> <div class="col-sm-offset-1 col-md-offset-3 col-sm-7 col-md-5 col-lg-4 m-b-lg">
<div class="last-update text-gray">
<span translate>{{ 'privacy.last_update' }}</span>
<span>{{ privacyBody.last_update | amDateFormat:'LL' }}</span>
</div>
<span ng-bind-html="privacyBody.value"></span> <span ng-bind-html="privacyBody.value"></span>
</div> </div>

View File

@ -53,6 +53,11 @@ class Setting < ActiveRecord::Base
last_value&.value last_value&.value
end end
def last_update
last_value = history_values.order(HistoryValue.arel_table['created_at'].desc).first
last_value&.created_at
end
def value=(val) def value=(val)
admin = User.admins.first admin = User.admins.first
save && history_values.create(user: admin, value: val) save && history_values.create(user: admin, value: val)

View File

@ -1 +1 @@
json.extract! setting, :name, :value json.extract! setting, :name, :value, :last_update

View File

@ -123,6 +123,7 @@ en:
privacy: privacy:
title: "Privacy policy" title: "Privacy policy"
dpo: "Data protection officer" dpo: "Data protection officer"
last_update: "Last update,"
home: home:
# home page # home page

View File

@ -122,6 +122,7 @@ es:
privacy: privacy:
title: "Política de privacidad" title: "Política de privacidad"
dpo: "Oficial de protección de datos" dpo: "Oficial de protección de datos"
last_update: "Última actualización,"
home: home:
# home page # home page

View File

@ -123,6 +123,7 @@ fr:
privacy: privacy:
title: "Politique de confidentialité" title: "Politique de confidentialité"
dpo: "Délégué à la protection des données" dpo: "Délégué à la protection des données"
last_update: "Dernière mise à jour,"
home: home:
# page d'accueil # page d'accueil

View File

@ -123,6 +123,7 @@ pt:
privacy: privacy:
title: "Política de privacidade" title: "Política de privacidade"
dpo: "Oficial de proteção de dados" dpo: "Oficial de proteção de dados"
last_update: "Última atualização,"
home: home:
# home page # home page