Skip to content

Commit 510c945

Browse files
committed
fix fields styling and condense
1 parent a434358 commit 510c945

File tree

15 files changed

+544
-1222
lines changed

15 files changed

+544
-1222
lines changed

web-app/admin/src/app/admin/admin-event/_shared-event-styles.scss

Lines changed: 420 additions & 41 deletions
Large diffs are not rendered by default.

web-app/admin/src/app/admin/admin-event/admin-event-form/fields-list/fields-list.component.html

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<!-- Detailed View (for edit form) -->
21
<div *ngIf="showDetailedView" class="fields-list-detailed">
3-
<mage-draggable-list [items]="getActiveFields()" [enableDragDrop]="enableDragDrop"
2+
<mage-draggable-list [items]="getActiveFields()" [enableDragDrop]="true"
43
[emptyMessage]="'No fields have been added yet.'" [emptyIcon]="'fa-file-text fa-3x'"
54
[trackByFunction]="trackByFieldId" (itemsChange)="onItemsReordered($event)">
65

@@ -58,30 +57,29 @@ <h4 class="field-title">{{ field.title || 'No title set' }}</h4>
5857
matTooltipPosition="above">
5958
<mat-icon>edit</mat-icon>
6059
</button>
61-
<button mat-icon-button (click)="$event.stopPropagation(); removeField(field)" matTooltip="Delete field"
60+
<button mat-icon-button (click)="$event.stopPropagation(); removeField(field)"
61+
[disabled]="!canRemoveField()"
62+
[matTooltip]="canRemoveField() ? 'Delete field' : 'Cannot delete last field'"
6263
matTooltipPosition="above">
6364
<mat-icon>delete</mat-icon>
6465
</button>
6566
</ng-template>
6667
</mage-draggable-list>
6768

6869
<div class="section-save-actions">
69-
<button class="action-button btn-primary" (click)="addField()">
70-
<i class="fa fa-plus"></i> Add Field
70+
<button type="button" class="action-button btn-primary" (click)="addField()">
71+
<i class="fa fa-plus"></i>
72+
Add Field
7173
</button>
7274
</div>
7375
</div>
7476

75-
<!-- Compact View (for create form) -->
7677
<div *ngIf="!showDetailedView" class="fields-list-compact">
77-
<mage-draggable-list [items]="getActiveFields()" [enableDragDrop]="false" [emptyMessage]="'No fields added yet'"
78+
<mage-draggable-list [items]="getActiveFields()" [enableDragDrop]="true" [emptyMessage]="'No fields added yet'"
7879
[emptyIcon]="'fa-inbox'" [trackByFunction]="trackByFieldId" (itemsChange)="onItemsReordered($event)">
7980

8081
<ng-template #itemTemplate let-field>
8182
<div class="field-content-compact">
82-
<div class="field-icon">
83-
<i class="fa fa-bars"></i>
84-
</div>
8583
<div class="field-info">
8684
<div class="field-title">{{ field.title }}</div>
8785
<div class="field-type">{{ getFieldTypeLabel(field.type) }}
@@ -92,9 +90,15 @@ <h4 class="field-title">{{ field.title || 'No title set' }}</h4>
9290
</ng-template>
9391

9492
<ng-template #itemActionsTemplate let-field>
95-
<button type="button" class="icon-button delete-button"
96-
(click)="$event.stopPropagation(); removeField(field)" title="Remove field">
97-
<i class="fa fa-trash"></i>
93+
<button mat-icon-button (click)="$event.stopPropagation(); editField(field)" matTooltip="Edit field"
94+
matTooltipPosition="above">
95+
<mat-icon>edit</mat-icon>
96+
</button>
97+
<button mat-icon-button (click)="$event.stopPropagation(); removeField(field)"
98+
[disabled]="!canRemoveField()"
99+
[matTooltip]="canRemoveField() ? 'Delete field' : 'Cannot delete last field'"
100+
matTooltipPosition="above">
101+
<mat-icon>delete</mat-icon>
98102
</button>
99103
</ng-template>
100104
</mage-draggable-list>

web-app/admin/src/app/admin/admin-event/admin-event-form/fields-list/fields-list.component.scss

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// Detailed View Styles (for edit form)
2-
.fields-list-detailed {
1+
@import '../../shared-event-styles';
2+
3+
.fields-list-detailed,
4+
::ng-deep .cdk-drag-preview {
35
.field-content-detailed {
46
flex: 1;
57
min-width: 0;
@@ -49,55 +51,47 @@
4951
color: #333;
5052
font-weight: 500;
5153
}
54+
}
5255

56+
.fields-list-detailed {
5357
.add-field-button-container {
5458
display: flex;
5559
justify-content: flex-start;
5660
margin-top: 1.5rem;
5761
}
5862

59-
.action-button {
60-
padding: 0.625rem 1.25rem;
61-
font-size: 0.875rem;
62-
font-weight: 500;
63-
border: none;
64-
border-radius: 4px;
65-
cursor: pointer;
66-
transition: background-color 0.2s;
67-
display: inline-flex;
68-
align-items: center;
69-
gap: 0.5rem;
63+
.drag-handle {
64+
cursor: move;
65+
color: #9e9e9e;
66+
margin-right: 8px;
7067

71-
&.btn-primary {
72-
background-color: #1976d2;
73-
color: white;
74-
75-
&:hover {
76-
background-color: #1565c0;
77-
}
78-
}
79-
80-
i {
81-
font-size: 0.875rem;
68+
&:hover {
69+
color: #616161;
8270
}
8371
}
8472

85-
.section-save-actions {
73+
.form-actions {
8674
display: flex;
87-
justify-content: flex-end;
88-
gap: 0.75rem;
89-
margin-top: 1.5rem;
90-
padding-top: 1.5rem;
91-
border-top: 1px solid #e5e7eb;
75+
gap: 8px;
76+
align-items: center;
77+
78+
button {
79+
display: flex;
80+
align-items: center;
81+
justify-content: center;
82+
83+
mat-icon {
84+
display: flex;
85+
align-items: center;
86+
justify-content: center;
87+
margin: 0;
88+
}
89+
}
9290
}
9391
}
9492

95-
// Compact View Styles (for create form)
96-
.fields-list-compact {
97-
display: flex;
98-
flex-direction: column;
99-
gap: 1.25rem;
100-
93+
.fields-list-compact,
94+
::ng-deep .cdk-drag-preview {
10195
.field-content-compact {
10296
display: flex;
10397
align-items: center;
@@ -140,34 +134,12 @@
140134
font-weight: 500;
141135
text-transform: uppercase;
142136
}
137+
}
143138

144-
.icon-button {
145-
background: none;
146-
border: none;
147-
cursor: pointer;
148-
padding: 0.5rem;
149-
color: #757575;
150-
transition: color 0.2s;
151-
display: flex;
152-
align-items: center;
153-
justify-content: center;
154-
155-
&:hover {
156-
color: #333;
157-
}
158-
159-
&.delete-button {
160-
color: #f44336;
161-
162-
&:hover {
163-
color: #d32f2f;
164-
}
165-
}
166-
167-
i {
168-
font-size: 1rem;
169-
}
170-
}
139+
.fields-list-compact {
140+
display: flex;
141+
flex-direction: column;
142+
gap: 1.25rem;
171143

172144
.add-field-button {
173145
align-self: flex-start;

web-app/admin/src/app/admin/admin-event/admin-event-form/fields-list/fields-list.component.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export class FieldsListComponent {
2929
@Input() fields: Field[] = [];
3030
@Input() fieldTypes: FieldType[] = [];
3131
@Input() attachmentAllowedTypes: AttachmentType[] = [];
32-
@Input() enableDragDrop: boolean = false;
3332
@Input() showDetailedView: boolean = false;
3433
@Output() fieldsChange = new EventEmitter<Field[]>();
3534

@@ -85,22 +84,26 @@ export class FieldsListComponent {
8584
}
8685

8786
/**
88-
* Removes a field from the list
87+
* Removes a field from the list (permanently deletes)
8988
*/
9089
removeField(field: Field): void {
91-
if (this.enableDragDrop) {
92-
// For edit mode, mark as archived instead of removing
93-
field.archived = true;
94-
} else {
95-
// For create mode, actually remove from array
96-
const index = this.fields.findIndex(f => f.id === field.id);
97-
if (index !== -1) {
98-
this.fields.splice(index, 1);
99-
}
90+
if (!this.canRemoveField()) {
91+
return;
92+
}
93+
const index = this.fields.findIndex(f => f.id === field.id);
94+
if (index !== -1) {
95+
this.fields.splice(index, 1);
10096
}
10197
this.fieldsChange.emit(this.fields);
10298
}
10399

100+
/**
101+
* Checks if a field can be removed (must have at least one active field)
102+
*/
103+
canRemoveField(): boolean {
104+
return this.showDetailedView && this.getActiveFields().length > 1;
105+
}
106+
104107
/**
105108
* Moves a field up in the list
106109
*/

web-app/admin/src/app/admin/admin-event/admin-event-form/form-details/field-dialog/field-dialog.component.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../../../shared-event-styles';
2+
13
::ng-deep .add-field-dialog {
24
.mat-mdc-dialog-container {
35
--mdc-dialog-container-color: #ffffff;

web-app/admin/src/app/admin/admin-event/admin-event-form/form-details/form-details.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ <h3 class="section-title">Fields</h3>
125125

126126
<!-- Use the fields-list component -->
127127
<mage-fields-list [fields]="form.fields || []" [fieldTypes]="fieldTypes"
128-
[attachmentAllowedTypes]="attachmentAllowedTypes" [enableDragDrop]="true"
128+
[attachmentAllowedTypes]="attachmentAllowedTypes"
129129
[showDetailedView]="true" (fieldsChange)="onFieldsChange($event)">
130130
</mage-fields-list>
131131
</div>

0 commit comments

Comments
 (0)