mirror of https://github.com/Squidex/squidex.git
106 changed files with 829 additions and 514 deletions
@ -1,14 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Assets.Commands |
|
||||
{ |
|
||||
public sealed class RenameAsset : AssetCommand |
|
||||
{ |
|
||||
public string FileName { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,44 @@ |
|||||
|
<form [formGroup]="annotateForm.form" (ngSubmit)="annotateAsset()"> |
||||
|
<sqx-modal-dialog (close)="emitCancel()"> |
||||
|
<ng-container title> |
||||
|
Update Asset |
||||
|
</ng-container> |
||||
|
|
||||
|
<ng-container content> |
||||
|
<sqx-form-error [error]="annotateForm.error | async"></sqx-form-error> |
||||
|
|
||||
|
<div class="form-group"> |
||||
|
<label for="fileName">Name</label> |
||||
|
|
||||
|
<sqx-control-errors for="fileName" [submitted]="annotateForm.submitted | async"></sqx-control-errors> |
||||
|
|
||||
|
<input type="text" class="form-control" id="fileName" formControlName="fileName" /> |
||||
|
</div> |
||||
|
|
||||
|
<div class="form-group"> |
||||
|
<label for="slug">Slug</label> |
||||
|
|
||||
|
<sqx-control-errors for="slug" [submitted]="annotateForm.submitted | async"></sqx-control-errors> |
||||
|
|
||||
|
<input type="text" class="form-control slug" id="slug" formControlName="slug" sqxTransformInput="Slugify" /> |
||||
|
|
||||
|
<button type="button" class="btn btn-text-secondary btn-sm btn-generate" (click)="generateSlug()"> |
||||
|
Generate |
||||
|
</button> |
||||
|
</div> |
||||
|
|
||||
|
<div class="form-group"> |
||||
|
<label for="tags">Tags</label> |
||||
|
|
||||
|
<sqx-control-errors for="tags" [submitted]="annotateForm.submitted | async"></sqx-control-errors> |
||||
|
|
||||
|
<sqx-tag-editor [suggestions]="allTags" [allowDuplicates]="false" [undefinedWhenEmpty]="false" formControlName="tags"></sqx-tag-editor> |
||||
|
</div> |
||||
|
</ng-container> |
||||
|
|
||||
|
<ng-container footer> |
||||
|
<button type="reset" class="float-left btn btn-secondary" (click)="emitCancel()">Cancel</button> |
||||
|
<button type="submit" class="float-right btn btn-primary">Save</button> |
||||
|
</ng-container> |
||||
|
</sqx-modal-dialog> |
||||
|
</form> |
||||
@ -0,0 +1,20 @@ |
|||||
|
@import '_vars'; |
||||
|
@import '_mixins'; |
||||
|
|
||||
|
.form-group { |
||||
|
position: relative; |
||||
|
} |
||||
|
|
||||
|
.slug { |
||||
|
padding-right: 6rem; |
||||
|
} |
||||
|
|
||||
|
.btn-generate { |
||||
|
& { |
||||
|
@include absolute(auto, 10px, 3px, auto); |
||||
|
} |
||||
|
|
||||
|
&:focus { |
||||
|
@include box-shadow-none; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; |
||||
|
import { FormBuilder } from '@angular/forms'; |
||||
|
|
||||
|
import { |
||||
|
AnnotateAssetForm, |
||||
|
AppsState, |
||||
|
AssetDto, |
||||
|
AssetsService, |
||||
|
AuthService, |
||||
|
StatefulComponent |
||||
|
} from '@app/shared/internal'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'sqx-asset-dialog', |
||||
|
styleUrls: ['./asset-dialog.component.scss'], |
||||
|
templateUrl: './asset-dialog.component.html', |
||||
|
changeDetection: ChangeDetectionStrategy.OnPush |
||||
|
}) |
||||
|
export class AssetDialogComponent extends StatefulComponent implements OnInit { |
||||
|
@Input() |
||||
|
public asset: AssetDto; |
||||
|
|
||||
|
@Input() |
||||
|
public allTags: string[]; |
||||
|
|
||||
|
@Output() |
||||
|
public cancel = new EventEmitter(); |
||||
|
|
||||
|
@Output() |
||||
|
public complete = new EventEmitter<AssetDto>(); |
||||
|
|
||||
|
public annotateForm = new AnnotateAssetForm(this.formBuilder); |
||||
|
|
||||
|
constructor(changeDetector: ChangeDetectorRef, |
||||
|
private readonly appsState: AppsState, |
||||
|
private readonly assetsService: AssetsService, |
||||
|
private readonly authState: AuthService, |
||||
|
private readonly formBuilder: FormBuilder |
||||
|
) { |
||||
|
super(changeDetector, { |
||||
|
isRenaming: false, |
||||
|
isTagging: false, |
||||
|
progress: 0 |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public ngOnInit() { |
||||
|
this.annotateForm.load(this.asset); |
||||
|
} |
||||
|
|
||||
|
public generateSlug() { |
||||
|
this.annotateForm.generateSlug(this.asset); |
||||
|
} |
||||
|
|
||||
|
public emitCancel() { |
||||
|
this.cancel.emit(); |
||||
|
} |
||||
|
|
||||
|
public emitComplete(asset: AssetDto) { |
||||
|
this.complete.emit(asset); |
||||
|
} |
||||
|
|
||||
|
public annotateAsset() { |
||||
|
const value = this.annotateForm.submit(this.asset); |
||||
|
|
||||
|
if (value) { |
||||
|
this.assetsService.putAsset(this.appsState.appName, this.asset.id, value, this.asset.version) |
||||
|
.subscribe(dto => { |
||||
|
this.emitComplete(this.asset.annnotate(value, this.authState.user!.token, dto.version)); |
||||
|
}, error => { |
||||
|
this.annotateForm.submitFailed(error); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue