1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing settings AlbumCover sorting #706

This commit is contained in:
Patrik J. Braun 2023-09-01 08:38:46 +02:00
parent c8ca71bf41
commit 7b7afc01f0
3 changed files with 66 additions and 6 deletions

View File

@ -1,22 +1,37 @@
import {propertyTypes} from 'typeconfig/common'; import {propertyTypes} from 'typeconfig/common';
/**
* Configuration in these class have a custom UI
*/
export class CustomSettingsEntries { export class CustomSettingsEntries {
public static readonly entries = ['ClientSortingConfig', 'ClientGroupingConfig', 'SVGIconConfig']; public static readonly entries = ['ClientSortingConfig', 'ClientGroupingConfig', 'SVGIconConfig'];
static getName(s: { tags?: { uiType?: string }, type?: propertyTypes }): string { public static getConfigName(s: { tags?: { uiType?: string }, type?: propertyTypes, arrayType?: propertyTypes }): string {
let c = s.tags?.uiType; let c = s.tags?.uiType;
try { try {
if (!c) { if (!c) {
if (s.arrayType) {
c = Object.getPrototypeOf(Object.getPrototypeOf(s?.arrayType))?.name;
} else {
c = Object.getPrototypeOf(Object.getPrototypeOf(s?.type))?.name; c = Object.getPrototypeOf(Object.getPrototypeOf(s?.type))?.name;
} }
}
} catch (e) { } catch (e) {
// no action // no action
} }
return c; return c;
} }
public static getFullName(s: { tags?: { uiType?: string }, type?: propertyTypes, arrayType?: propertyTypes }): string {
const cN = this.getConfigName(s);
if (!s.tags?.uiType && s.arrayType) {
return cN + '-Array';
}
return cN;
}
public static iS(s: { tags?: { uiType?: string }, type?: propertyTypes }) { public static iS(s: { tags?: { uiType?: string }, type?: propertyTypes }) {
const c = this.getName(s); const c = this.getConfigName(s);
return this.entries.includes(c); return this.entries.includes(c);
} }
} }

View File

@ -275,8 +275,9 @@
[name]="'list_ml_url_'+idName+i" [id]="'list_ml_url_'+idName+i" required> [name]="'list_ml_url_'+idName+i" [id]="'list_ml_url_'+idName+i" required>
</td> </td>
<td> <td>
<button [disabled]="state.value.length == 1" (click)="removeLayer(layer)" <button [disabled]="state.value.length == 1"
[ngClass]="state.value.length > 1? 'btn-danger':'btn-secondary'" [ngClass]="state.value.length > 1? 'btn-danger':'btn-secondary'"
(click)="removeLayer(layer)"
class="btn float-end"> class="btn float-end">
<ng-icon name="ionTrashOutline" title="Delete" i18n-title></ng-icon> <ng-icon name="ionTrashOutline" title="Delete" i18n-title></ng-icon>
</button> </button>
@ -533,6 +534,48 @@
</div> </div>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'ClientSortingConfig-Array'">
<ng-container *ngFor="let _ of state.value; let i=index">
<div class="row col-12 mt-1 m-0 p-0">
<div class="col p-0">
<app-settings-entry-sorting-method
class="w-100"
[(ngModel)]="state.value[i]"
[sortingByEnum]="SortByTypes"
[id]="'list_'+idName+i"
[name]="'list_'+idName+i"
(ngModelChange)="onChange($event)">
</app-settings-entry-sorting-method>
</div>
<ng-container>
<div class="col-auto pe-0">
<button class="btn float-end"
[disabled]="state.value.length == 1"
[ngClass]="state.value.length > 1? 'btn-danger':'btn-secondary'"
[id]="'list_btn_'+idName+i"
[name]="'list_btn_'+idName+i" (click)="remove(i)">
<ng-icon name="ionTrashOutline" title="Delete" i18n-title></ng-icon>
</button>
</div>
</ng-container>
</div>
</ng-container>
<ng-container>
<div class="col-12 p-0">
<button class="btn btn-primary mt-1 float-end"
[id]="'btn_add_'+idName"
[name]="'btn_add_'+idName"
(click)="AddNew()">
<ng-icon name="ionAddOutline" class="me-1"></ng-icon>
<span i18n>Add</span>
</button>
</div>
</ng-container>
</ng-container>
<ng-container *ngSwitchCase="'EnumArray'"> <ng-container *ngSwitchCase="'EnumArray'">
<ng-container *ngFor="let _ of state.value; let i=index"> <ng-container *ngFor="let _ of state.value; let i=index">
<div class="row col-12 mt-1 m-0 p-0"> <div class="row col-12 mt-1 m-0 p-0">
@ -552,7 +595,9 @@
</div> </div>
<ng-container> <ng-container>
<div class="col-auto pe-0"> <div class="col-auto pe-0">
<button class="btn btn-secondary float-end" <button class="btn float-end"
[disabled]="state.value.length == 1"
[ngClass]="state.value.length > 1? 'btn-danger':'btn-secondary'"
[id]="'list_btn_'+idName+i" [id]="'list_btn_'+idName+i"
[name]="'list_btn_'+idName+i" (click)="remove(i)"> [name]="'list_btn_'+idName+i" (click)="remove(i)">
<ng-icon name="ionTrashOutline" title="Delete" i18n-title></ng-icon> <ng-icon name="ionTrashOutline" title="Delete" i18n-title></ng-icon>

View File

@ -239,7 +239,7 @@ export class SettingsEntryComponent
} }
this.uiType = this.arrayType; this.uiType = this.arrayType;
if(CustomSettingsEntries.iS(this.state)){ if(CustomSettingsEntries.iS(this.state)){
this.uiType = CustomSettingsEntries.getName(this.state); this.uiType = CustomSettingsEntries.getFullName(this.state);
} }
if (!this.state.isEnumType && if (!this.state.isEnumType &&
!this.state.isEnumArrayType && !this.state.isEnumArrayType &&