Skip to content

Commit a54c4a5

Browse files
committed
feat: allow to activate / deactivate edition in back-office, to preview changes
1 parent e60ca8b commit a54c4a5

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ <h1 class="!m-0 overflow-hidden text-ellipsis">
3535
icon="settings"
3636
[uiTooltip]="'common.settings' | translate"
3737
></ui-button>
38+
<ui-button
39+
*ngIf="canUpdate"
40+
[icon]="editionActive ? 'edit' : 'preview'"
41+
(click)="editionActive = !editionActive"
42+
>{{
43+
(editionActive
44+
? 'components.application.dashboard.enterPreviewMode'
45+
: 'components.application.dashboard.enterEditMode')
46+
| translate
47+
}}</ui-button
48+
>
3849
</div>
50+
<!-- Other dashboard settings -->
3951
<div
4052
class="flex items-center gap-1"
4153
*ngIf="!formActive"
@@ -164,7 +176,7 @@ <h1 class="!m-0 overflow-hidden text-ellipsis">
164176
<shared-widget-grid
165177
[loading]="loading"
166178
[widgets]="widgets"
167-
[canUpdate]="dashboard?.canUpdate || false"
179+
[canUpdate]="(canUpdate && editionActive) || false"
168180
(move)="onMove($event)"
169181
(edit)="onEditTile($event)"
170182
(delete)="onDeleteTile($event)"

apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
ApplicationService,
1717
WorkflowService,
1818
DashboardService,
19-
AuthService,
2019
Application,
2120
UnsubscribeComponent,
2221
WidgetGridComponent,
@@ -109,8 +108,10 @@ export class DashboardComponent
109108
public contextRecord: Record | null = null;
110109
/** Configured dashboard quick actions */
111110
public buttonActions: ButtonActionT[] = [];
112-
111+
/** Timeout to scroll to newly added widget */
113112
private timeoutListener!: NodeJS.Timeout;
113+
/** Is edition active */
114+
public editionActive = true;
114115

115116
/** @returns get newest widget id from existing ids */
116117
get newestId(): number {
@@ -147,7 +148,6 @@ export class DashboardComponent
147148
* @param snackBar Shared snackbar service
148149
* @param dashboardService Shared dashboard service
149150
* @param translate Angular translate service
150-
* @param authService Shared authentication service
151151
* @param confirmService Shared confirm service
152152
* @param contextService Dashboard context service
153153
* @param refDataService Shared reference data service
@@ -167,7 +167,6 @@ export class DashboardComponent
167167
private snackBar: SnackbarService,
168168
private dashboardService: DashboardService,
169169
private translate: TranslateService,
170-
private authService: AuthService,
171170
private confirmService: ConfirmService,
172171
private contextService: ContextService,
173172
private refDataService: ReferenceDataService,
@@ -294,6 +293,7 @@ export class DashboardComponent
294293
return;
295294
}
296295

296+
this.editionActive = true;
297297
const rootElement = this.elementRef.nativeElement;
298298
this.renderer.setAttribute(rootElement, 'data-dashboard-id', id);
299299
this.formActive = false;

libs/shared/src/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@
512512
"dashboard": {
513513
"editFilter": "Edit filter",
514514
"empty": "No content available. Wait for your administrator to build some.",
515+
"enterEditMode": "Enter edit mode",
516+
"enterPreviewMode": "Enter preview mode",
515517
"filter": {
516518
"empty": "No filters have been defined by the administrators",
517519
"filterPosition": {

libs/shared/src/i18n/fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@
512512
"dashboard": {
513513
"editFilter": "Modifier le filtre",
514514
"empty": "Aucun contenu n'est disponible. Veuillez attendre que votre administrateur en crée.",
515+
"enterEditMode": "Entrer en mode édition",
516+
"enterPreviewMode": "Entrer en mode prévisualisation",
515517
"filter": {
516518
"empty": "Aucun filtre n'a été défini par les administrateurs",
517519
"filterPosition": {

libs/shared/src/i18n/test.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@
512512
"dashboard": {
513513
"editFilter": "******",
514514
"empty": "******",
515+
"enterEditMode": "******",
516+
"enterPreviewMode": "******",
515517
"filter": {
516518
"empty": "******",
517519
"filterPosition": {

libs/shared/src/lib/components/widget-grid/widget-grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h2 *ngIf="widgets.length === 0">{{ 'models.widget.add' | translate }}</h2>
1818
[columns]="colsNumber"
1919
[rowHeight]="200"
2020
[resizable]="canUpdate"
21-
[reorderable]="true"
21+
[reorderable]="canUpdate"
2222
(reorder)="onReorder($event)"
2323
(resize)="onResize($event)"
2424
class="-m-4"

0 commit comments

Comments
 (0)