[DSC-1111] Start implementation refactoring

This commit is contained in:
Giuseppe Digilio
2024-02-13 12:05:30 +01:00
committed by Mattia Vianelli
parent b017f9ad16
commit 6d98bf9d3a
4 changed files with 13 additions and 14 deletions

View File

@@ -12,7 +12,7 @@ import {
import { Collection } from '../../core/shared/collection.model'; import { Collection } from '../../core/shared/collection.model';
import { ComColFormComponent } from '../../shared/comcol/comcol-forms/comcol-form/comcol-form.component'; import { ComColFormComponent } from '../../shared/comcol/comcol-forms/comcol-form/comcol-form.component';
import { NotificationsService } from '../../shared/notifications/notifications.service'; import { NotificationsService } from '../../shared/notifications/notifications.service';
import { CommunityDataService } from '../../core/data/community-data.service'; import { CollectionDataService } from '../../core/data/collection-data.service';
import { AuthService } from '../../core/auth/auth.service'; import { AuthService } from '../../core/auth/auth.service';
import { RequestService } from '../../core/data/request.service'; import { RequestService } from '../../core/data/request.service';
import { ObjectCacheService } from '../../core/cache/object-cache.service'; import { ObjectCacheService } from '../../core/cache/object-cache.service';
@@ -60,7 +60,7 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
protected translate: TranslateService, protected translate: TranslateService,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected authService: AuthService, protected authService: AuthService,
protected dsoService: CommunityDataService, protected dsoService: CollectionDataService,
protected requestService: RequestService, protected requestService: RequestService,
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
protected entityTypeService: EntityTypeDataService, protected entityTypeService: EntityTypeDataService,

View File

@@ -4,8 +4,7 @@
<span>{{type.value + '.edit.logo.label' | translate}}</span> <span>{{type.value + '.edit.logo.label' | translate}}</span>
</div> </div>
<ng-container *ngVar="(dso?.logo | async)?.payload as logo"> <ng-container *ngVar="(dso?.logo | async)?.payload as logo">
<div *ngIf="logo" [ngClass]="{'alert-danger': markLogoForDeletion}" class="col-12 d-inline-block alert" <div class="col-12 d-inline-block alert" [ngClass]="{'alert-danger': markLogoForDeletion}" id="logo-section" *ngIf="logo">
id="logo-section">
<div class="row"> <div class="row">
<div class="col-8 d-inline-block"> <div class="col-8 d-inline-block">
<ds-comcol-page-logo [alternateText]="type.value + '.logo.alt'" [logo]="logo"></ds-comcol-page-logo> <ds-comcol-page-logo [alternateText]="type.value + '.logo.alt'" [logo]="logo"></ds-comcol-page-logo>
@@ -44,8 +43,11 @@
</ng-container> </ng-container>
</div> </div>
</div> </div>
<ds-form (submitForm)="onSubmit()" *ngIf="formModel" [displayCancel]="false" [formId]="'comcol-form-id'" <ds-form *ngIf="formModel"
[formModel]="formModel"> [formId]="'comcol-form-id'"
[formModel]="formModel"
[displayCancel]="false"
(submitForm)="onSubmit()">
<button (click)="back.emit()" before class="btn btn-outline-secondary" type="button"> <button (click)="back.emit()" before class="btn btn-outline-secondary" type="button">
<i class="fas fa-arrow-left" aria-hidden="true"></i> {{ type.value + '.edit.return' | translate }} <i class="fas fa-arrow-left" aria-hidden="true"></i> {{ type.value + '.edit.return' | translate }}
</button> </button>

View File

@@ -75,7 +75,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
* @type {UploaderOptions} * @type {UploaderOptions}
*/ */
uploadFilesOptions: UploaderOptions = Object.assign(new UploaderOptions(), { uploadFilesOptions: UploaderOptions = Object.assign(new UploaderOptions(), {
autoUpload: false autoUpload: true
}); });
/** /**
@@ -155,9 +155,9 @@ export class ComColFormComponent<T extends Collection | Community> implements On
this.uploadFilesOptions.url = href; this.uploadFilesOptions.url = href;
this.uploadFilesOptions.authToken = this.authService.buildAuthHeader(); this.uploadFilesOptions.authToken = this.authService.buildAuthHeader();
// If the object already contains a logo, send out a PUT request instead of POST for setting a new logo // If the object already contains a logo, send out a PUT request instead of POST for setting a new logo
if (hasValue(logoRD.payload)) { // if (hasValue(logoRD.payload)) {
this.uploadFilesOptions.method = RestRequestMethod.PUT; // this.uploadFilesOptions.method = RestRequestMethod.PUT;
} // }
this.initializedUploaderOptions.next(true); this.initializedUploaderOptions.next(true);
}) })
); );
@@ -317,7 +317,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
this.refreshCache(); this.refreshCache();
} }
this.notificationsService.success(null, this.translate.get(this.type.value + '.edit.logo.notifications.add.success')); this.notificationsService.success(null, this.translate.get(this.type.value + '.edit.logo.notifications.add.success'));
this.finish.emit(); // this.finish.emit();
} }
/** /**

View File

@@ -130,9 +130,6 @@ export class UploaderComponent {
ngAfterViewInit() { ngAfterViewInit() {
this.uploader.onAfterAddingAll = ((items) => { this.uploader.onAfterAddingAll = ((items) => {
this.onFileSelected.emit(items); this.onFileSelected.emit(items);
if (this.uploader.queue.length > 0) {
this.uploader.uploadAll();
}
}); });
if (isUndefined(this.onBeforeUpload)) { if (isUndefined(this.onBeforeUpload)) {
this.onBeforeUpload = () => {return;}; this.onBeforeUpload = () => {return;};