Browse Source

Archive feature and bugfixes.

pull/107/head
Sebastian Stehle 9 years ago
parent
commit
0fcb6b139d
  1. 2
      src/Squidex/Controllers/Api/Schemas/SchemasController.cs
  2. 11
      src/Squidex/app/features/content/pages/content/content-page.component.html
  3. 10
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  4. 18
      src/Squidex/app/features/content/pages/contents/contents-page.component.html
  5. 78
      src/Squidex/app/features/content/pages/contents/contents-page.component.ts
  6. 2
      src/Squidex/app/features/content/pages/contents/search-form.component.html
  7. 3
      src/Squidex/app/features/content/pages/contents/search-form.component.ts
  8. 2
      src/Squidex/app/features/content/pages/messages.ts
  9. 12
      src/Squidex/app/features/content/shared/content-item.component.html
  10. 6
      src/Squidex/app/features/content/shared/content-item.component.ts
  11. 4
      src/Squidex/app/features/content/shared/references-editor.component.ts
  12. 2
      src/Squidex/app/shared/services/contents.service.ts

2
src/Squidex/Controllers/Api/Schemas/SchemasController.cs

@ -125,7 +125,7 @@ namespace Squidex.Controllers.Api.Schemas
var context = await CommandBus.PublishAsync(command);
var result = context.Result<EntityCreatedResult<Guid>>();
var response = new EntityCreatedDto { Id = command.Name, Version = result.Version };
var response = new EntityCreatedDto { Id = command.SchemaId.ToString(), Version = result.Version };
return CreatedAtAction(nameof(GetSchema), new { name = request.Name }, response);
}

11
src/Squidex/app/features/content/pages/content/content-page.component.html

@ -4,7 +4,7 @@
<sqx-panel panelWidth="53rem">
<div class="panel-header">
<div class="panel-title-row">
<div class="float-right">
<div class="float-right" *ngIf="!content || !content.isArchived">
<span *ngIf="isNewMode">
<button type="button" class="btn btn-secondary" (click)="saveAsDraft()" title="CTRL + S">
Save as Draft
@ -19,16 +19,19 @@
Save
</button>
</span>
</div>
<sqx-shortcut keys="ctrl+s" (trigger)="saveAndPublish()"></sqx-shortcut>
<sqx-shortcut keys="ctrl+s" (trigger)="saveAndPublish()"></sqx-shortcut>
</div>
<h3 class="panel-title" *ngIf="isNewMode">
New Content
</h3>
<h3 class="panel-title" *ngIf="!isNewMode">
<h3 class="panel-title" *ngIf="!isNewMode && !content.isArchived">
Edit Content
</h3>
<h3 class="panel-title" *ngIf="!isNewMode && content.isArchived">
Show Content
</h3>
</div>
<a class="panel-close" sqxParentLink>

10
src/Squidex/app/features/content/pages/content/content-page.component.ts

@ -12,7 +12,7 @@ import { Observable, Subscription } from 'rxjs';
import {
ContentCreated,
ContentDeleted,
ContentRemoved,
ContentUpdated,
ContentVersionSelected
} from './../messages';
@ -40,10 +40,10 @@ import {
export class ContentPageComponent extends AppComponentBase implements CanComponentDeactivate, OnDestroy, OnInit {
private contentDeletedSubscription: Subscription;
private contentVersionSelectedSubscription: Subscription;
private content: ContentDto;
public schema: SchemaDetailsDto;
public content: ContentDto;
public contentFormSubmitted = false;
public contentForm: FormGroup;
@ -78,7 +78,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone
});
this.contentDeletedSubscription =
this.messageBus.of(ContentDeleted)
this.messageBus.of(ContentRemoved)
.subscribe(message => {
if (this.content && message.content.id === this.content.id) {
this.router.navigate(['../'], { relativeTo: this.route });
@ -232,6 +232,10 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone
fieldForm.controls['iv'].setValue(fieldValue['iv']);
}
}
if (this.content.isArchived) {
this.contentForm.disable();
}
}
}
}

18
src/Squidex/app/features/content/pages/contents/contents-page.component.html

@ -21,7 +21,13 @@
</form>
<div class="dropdown-menu" *sqxModalView="searchModal" closeAlways="true" [sqxModalTarget]="searchInput" position="right">
<sqx-search-form (queryChanged)="contentsFilter.setValue($event, { emitEvent: false })" [query]="contentsFilter.value"></sqx-search-form>
<sqx-search-form
[canArchive]="!isReadOnly"
(queryChanged)="contentsFilter.setValue($event, { emitEvent: false })"
[query]="contentsFilter.value"
(archivedChanged)="updateArchive($event)"
[archived]="isArchive">
</sqx-search-form>
</div>
<span *ngIf="!isReadOnly && languages.length > 1">
@ -33,12 +39,16 @@
</button>
</div>
<h3 class="panel-title" *ngIf="!isReadOnly">
<h3 class="panel-title" *ngIf="!isReadOnly && !isArchive">
Contents
</h3>
<h3 class="panel-title" *ngIf="isArchive">
Archive
</h3>
<h3 class="panel-title" *ngIf="isReadOnly">
References
Refs
</h3>
</div>
@ -82,6 +92,8 @@
[schema]="schema"
(unpublishing)="unpublishContent(content)"
(publishing)="publishContent(content)"
(archiving)="archiveContent(content)"
(restoring)="restoreContent(content)"
(deleting)="deleteContent(content)"></tr>
<tr class="spacer"></tr>
</ng-template>

78
src/Squidex/app/features/content/pages/contents/contents-page.component.ts

@ -12,7 +12,7 @@ import { Subscription } from 'rxjs';
import {
ContentCreated,
ContentDeleted,
ContentRemoved,
ContentUpdated
} from './../messages';
@ -57,6 +57,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
public languageParameter: string;
public isReadOnly = false;
public isArchive = false;
public columnWidth: number;
@ -112,13 +113,6 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
return { content, schemaId: this.schema.id };
}
public search() {
this.contentsQuery = this.contentsFilter.value;
this.contentsPager = new Pager(0);
this.load();
}
public publishContent(content: ContentDto) {
this.appNameOnce()
.switchMap(app => this.contentsService.publishContent(app, this.schema.name, content.id, content.version))
@ -139,14 +133,35 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
});
}
public archiveContent(content: ContentDto) {
this.appNameOnce()
.switchMap(app => this.contentsService.archiveContent(app, this.schema.name, content.id, content.version))
.subscribe(() => {
content = content.archive(this.authService.user!.token);
this.removeContent(content);
}, error => {
this.notifyError(error);
});
}
public restoreContent(content: ContentDto) {
this.appNameOnce()
.switchMap(app => this.contentsService.restoreContent(app, this.schema.name, content.id, content.version))
.subscribe(() => {
content = content.restore(this.authService.user!.token);
this.removeContent(content);
}, error => {
this.notifyError(error);
});
}
public deleteContent(content: ContentDto) {
this.appNameOnce()
.switchMap(app => this.contentsService.deleteContent(app, this.schema.name, content.id, content.version))
.subscribe(() => {
this.contentItems = this.contentItems.removeAll(x => x.id === content.id);
this.contentsPager = this.contentsPager.decrementCount();
this.emitContentDeleted(content);
this.removeContent(content);
}, error => {
this.notifyError(error);
});
@ -154,7 +169,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
public load(showInfo = false) {
this.appNameOnce()
.switchMap(app => this.contentsService.getContents(app, this.schema.name, this.contentsPager.pageSize, this.contentsPager.skip, this.contentsQuery))
.switchMap(app => this.contentsService.getContents(app, this.schema.name, this.contentsPager.pageSize, this.contentsPager.skip, this.contentsQuery, null, this.isArchive))
.subscribe(dtos => {
this.contentItems = ImmutableArray.of(dtos.items);
this.contentsPager = this.contentsPager.setCount(dtos.total);
@ -167,8 +182,22 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
});
}
public selectLanguage(language: AppLanguageDto) {
this.languageSelected = language;
public updateArchive(isArchive: boolean) {
this.contentsQuery = this.contentsFilter.value;
this.contentsPager = new Pager(0);
this.isArchive = isArchive;
this.searchModal.hide();
this.load();
}
public search() {
this.contentsQuery = this.contentsFilter.value;
this.contentsPager = new Pager(0);
this.load();
}
public goNext() {
@ -183,8 +212,12 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.load();
}
private emitContentDeleted(content: ContentDto) {
this.messageBus.emit(new ContentDeleted(content));
public selectLanguage(language: AppLanguageDto) {
this.languageSelected = language;
}
private emitContentRemoved(content: ContentDto) {
this.messageBus.emit(new ContentRemoved(content));
}
private resetContents() {
@ -196,6 +229,13 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.loadFields();
}
private removeContent(content: ContentDto) {
this.contentItems = this.contentItems.removeAll(x => x.id === content.id);
this.contentsPager = this.contentsPager.decrementCount();
this.emitContentRemoved(content);
}
private loadFields() {
this.contentFields = this.schema.fields.filter(x => x.properties.isListField);
@ -203,6 +243,10 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.contentFields = [this.schema.fields[0]];
}
if (this.contentFields.length === 0) {
this.contentFields = [<any>{}];
}
if (this.contentFields.length > 0) {
this.columnWidth = 100 / this.contentFields.length;
} else {

2
src/Squidex/app/features/content/pages/contents/search-form.component.html

@ -25,7 +25,7 @@
</div>
</div>
<div class="form-check">
<div class="form-check" *ngIf="canArchive">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" [ngModel]="archived" (ngModelChange)="archivedChanged.emit($event)" /> Archived items
</label>

3
src/Squidex/app/features/content/pages/contents/search-form.component.ts

@ -28,6 +28,9 @@ export class SearchFormComponent implements OnChanges {
@Output()
public archivedChanged = new EventEmitter<boolean>();
@Input()
public canArchive = true;
public searchForm =
this.formBuilder.group({
odataOrderBy: '',

2
src/Squidex/app/features/content/pages/messages.ts

@ -21,7 +21,7 @@ export class ContentUpdated {
}
}
export class ContentDeleted {
export class ContentRemoved {
constructor(
public readonly content: ContentDto
) {

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

@ -17,13 +17,19 @@
<i class="icon-dots"></i>
</button>
<div class="dropdown-menu" *sqxModalView="dropdown" closeAlways="true" [sqxModalTarget]="optionsButton" position="right" [@fade]>
<a class="dropdown-item" (click)="publishing.emit(); $event.stopPropagation()" *ngIf="!content.isPublished">
<a class="dropdown-item" (click)="publishing.emit(); $event.stopPropagation()" *ngIf="!content.isPublished && !content.isArchived">
Publish
</a>
<a class="dropdown-item" (click)="unpublishing.emit(); $event.stopPropagation()" *ngIf="content.isPublished">
<a class="dropdown-item" (click)="unpublishing.emit(); $event.stopPropagation()" *ngIf="content.isPublished && !content.isArchived">
Unpublish
</a>
<a class="dropdown-item dropdown-item-delete"
<a class="dropdown-item" (click)="archiving.emit(); $event.stopPropagation()" *ngIf="!content.isArchived">
Archive
</a>
<a class="dropdown-item" (click)="restoring.emit(); $event.stopPropagation()" *ngIf="content.isArchived">
Restore
</a>
<a class="dropdown-item dropdown-item-delete" *ngIf="content.isArchived"
(sqxConfirmClick)="deleting.emit()"
confirmTitle="Delete content"
confirmText="Do you really want to delete the content?">

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

@ -35,6 +35,12 @@ export class ContentItemComponent extends AppComponentBase implements OnInit, On
@Output()
public unpublishing = new EventEmitter<ContentDto>();
@Output()
public archiving = new EventEmitter<ContentDto>();
@Output()
public restoring = new EventEmitter<ContentDto>();
@Output()
public deleting = new EventEmitter<ContentDto>();

4
src/Squidex/app/features/content/shared/references-editor.component.ts

@ -148,6 +148,10 @@ export class ReferencesEditorComponent extends AppComponentBase implements Contr
this.contentFields = [this.schema.fields[0]];
}
if (this.contentFields.length === 0) {
this.contentFields = [<any>{}];
}
if (this.contentFields.length > 0) {
this.columnWidth = 100 / this.contentFields.length;
} else {

2
src/Squidex/app/shared/services/contents.service.ts

@ -160,7 +160,7 @@ export class ContentsService {
return new ContentDto(
item.id,
item.isPublished,
item.isDeleted === true,
item.isArchived === true,
item.createdBy,
item.lastModifiedBy,
DateTime.parseISO_UTC(item.created),

Loading…
Cancel
Save