Browse Source

Inline editing (patch) fixed.

pull/363/head
Sebastian Stehle 7 years ago
parent
commit
293d6db4c0
  1. 2
      src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs
  2. 2
      src/Squidex/app/features/content/shared/content-item.component.html
  3. 15
      src/Squidex/app/features/content/shared/content-item.component.ts

2
src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs

@ -130,6 +130,8 @@ namespace Squidex.Areas.Api.Controllers.Contents.Models
if (controller.HasPermission(Permissions.AppContentsUpdate, app, schema)) if (controller.HasPermission(Permissions.AppContentsUpdate, app, schema))
{ {
AddPatchLink("patch", controller.Url<ContentsController>(x => nameof(x.PatchContent), values));
AddPutLink("update", controller.Url<ContentsController>(x => nameof(x.PutContent), values)); AddPutLink("update", controller.Url<ContentsController>(x => nameof(x.PutContent), values));
if (Status == Status.Published) if (Status == Status.Published)

2
src/Squidex/app/features/content/shared/content-item.component.html

@ -12,7 +12,7 @@
</td> </td>
<td class="cell-auto" *ngFor="let field of schema.listFields; let i = index; trackBy: trackByField.bind(this)" [sqxStopClick]="isDirty || field.isInlineEditable"> <td class="cell-auto" *ngFor="let field of schema.listFields; let i = index; trackBy: trackByField.bind(this)" [sqxStopClick]="isDirty || field.isInlineEditable">
<ng-container *ngIf="field.isInlineEditable && !isReadOnly; else displayTemplate"> <ng-container *ngIf="field.isInlineEditable && patchAllowed; else displayTemplate">
<sqx-content-item-editor [form]="patchForm.form" [field]="field"></sqx-content-item-editor> <sqx-content-item-editor [form]="patchForm.form" [field]="field"></sqx-content-item-editor>
</ng-container> </ng-container>

15
src/Squidex/app/features/content/shared/content-item.component.ts

@ -74,13 +74,14 @@ export class ContentItemComponent implements OnChanges {
public content: ContentDto; public content: ContentDto;
public patchForm: PatchContentForm; public patchForm: PatchContentForm;
public patchAllowed = false;
public dropdown = new ModalModel(); public dropdown = new ModalModel();
public values: any[] = []; public values: any[] = [];
public get isDirty() { public get isDirty() {
return this.patchForm.form.dirty; return this.patchForm && this.patchForm.form.dirty;
} }
constructor( constructor(
@ -90,8 +91,14 @@ export class ContentItemComponent implements OnChanges {
} }
public ngOnChanges(changes: SimpleChanges) { public ngOnChanges(changes: SimpleChanges) {
if (changes['content']) {
this.patchAllowed = !this.isReadOnly && this.content.canUpdate;
}
if (changes['schema'] || changes['language']) { if (changes['schema'] || changes['language']) {
this.patchForm = new PatchContentForm(this.schema, this.language); if (this.patchAllowed) {
this.patchForm = new PatchContentForm(this.schema, this.language);
}
} }
if (changes['content'] || changes['language']) { if (changes['content'] || changes['language']) {
@ -100,6 +107,10 @@ export class ContentItemComponent implements OnChanges {
} }
public save() { public save() {
if (!this.content.canUpdate) {
return;
}
const value = this.patchForm.submit(); const value = this.patchForm.submit();
if (value) { if (value) {

Loading…
Cancel
Save