Browse Source

Renamings

pull/1/head
Sebastian 9 years ago
parent
commit
5b678a4ed3
  1. 8
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  2. 10
      src/Squidex/app/features/content/pages/contents/content-item.component.html
  3. 18
      src/Squidex/app/features/content/pages/contents/content-item.component.ts
  4. 6
      src/Squidex/app/features/content/pages/contents/contents-page.component.html
  5. 18
      src/Squidex/app/features/content/pages/contents/contents-page.component.ts
  6. 10
      src/Squidex/app/features/schemas/pages/schema/field.component.html
  7. 14
      src/Squidex/app/features/schemas/pages/schema/field.component.ts
  8. 12
      src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts
  9. 12
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.html
  10. 4
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts
  11. 12
      src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts
  12. 2
      src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
  13. 6
      src/Squidex/app/features/settings/pages/clients/client.component.ts
  14. 4
      src/Squidex/app/features/settings/pages/clients/clients-page.component.html
  15. 10
      src/Squidex/app/shared/components/app-form.component.ts

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

@ -46,11 +46,9 @@ export class ContentPageComponent extends AppComponentBase implements OnDestroy,
public contentData: any = null; public contentData: any = null;
public contentId: string; public contentId: string;
public languages: AppLanguageDto[] = []; public isNewMode = false;
public get isNewMode() { public languages: AppLanguageDto[] = [];
return !this.contentData;
}
constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService, constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService,
private readonly contentsService: ContentsService, private readonly contentsService: ContentsService,
@ -182,10 +180,12 @@ export class ContentPageComponent extends AppComponentBase implements OnDestroy,
if (!content) { if (!content) {
this.contentData = undefined; this.contentData = undefined;
this.contentId = undefined; this.contentId = undefined;
this.isNewMode = false;
return; return;
} else { } else {
this.contentData = content.data; this.contentData = content.data;
this.contentId = content.id; this.contentId = content.id;
this.isNewMode = true;
} }
for (const field of this.schema.fields) { for (const field of this.schema.fields) {

10
src/Squidex/app/features/content/pages/contents/content-item.component.html

@ -1,6 +1,6 @@
<td *ngFor="let field of fields"> <td *ngFor="let value of values">
<span class="field"> <span class="field">
{{getValue(field)}} {{value}}
</span> </span>
</td> </td>
<td> <td>
@ -16,13 +16,13 @@
<i class="icon-dots"></i> <i class="icon-dots"></i>
</button> </button>
<div class="dropdown-menu" *sqxModalView="dropdown" closeAlways="true" [@fade]> <div class="dropdown-menu" *sqxModalView="dropdown" closeAlways="true" [@fade]>
<a class="dropdown-item" (click)="published.emit(); $event.stopPropagation()" *ngIf="!content.isPublished"> <a class="dropdown-item" (click)="publishing.emit(); $event.stopPropagation()" *ngIf="!content.isPublished">
Publish Publish
</a> </a>
<a class="dropdown-item" (click)="unpublished.emit(); $event.stopPropagation()" *ngIf="content.isPublished"> <a class="dropdown-item" (click)="unpublishing.emit(); $event.stopPropagation()" *ngIf="content.isPublished">
Unpublish Unpublish
</a> </a>
<a class="dropdown-item" (click)="deleted.emit(); $event.stopPropagation()"> <a class="dropdown-item" (click)="deleting.emit(); $event.stopPropagation()">
Delete Delete
</a> </a>
</div> </div>

18
src/Squidex/app/features/content/pages/contents/content-item.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Sebastian Stehle. All rights reserved * Copyright (c) Sebastian Stehle. All rights reserved
*/ */
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { import {
AppComponentBase, AppComponentBase,
@ -28,17 +28,17 @@ import {
fadeAnimation fadeAnimation
] ]
}) })
export class ContentItemComponent extends AppComponentBase { export class ContentItemComponent extends AppComponentBase implements OnInit {
public dropdown = new ModalView(false, true); public dropdown = new ModalView(false, true);
@Output() @Output()
public published = new EventEmitter<ContentDto>(); public publishing = new EventEmitter<ContentDto>();
@Output() @Output()
public unpublished = new EventEmitter<ContentDto>(); public unpublishing = new EventEmitter<ContentDto>();
@Output() @Output()
public deleted = new EventEmitter<ContentDto>(); public deleting = new EventEmitter<ContentDto>();
@Input() @Input()
public fields: FieldDto[]; public fields: FieldDto[];
@ -52,10 +52,18 @@ export class ContentItemComponent extends AppComponentBase {
@Input('sqxContent') @Input('sqxContent')
public content: ContentDto; public content: ContentDto;
public values: any[] = [];
constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService) { constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService) {
super(apps, notifications, users); super(apps, notifications, users);
} }
public ngOnInit() {
for (let field of this.fields) {
this.values.push(this.getValue(field));
}
}
public getValue(field: FieldDto): any { public getValue(field: FieldDto): any {
const contentField = this.content.data[field.name]; const contentField = this.content.data[field.name];

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

@ -57,9 +57,9 @@
[language]="languageSelected" [language]="languageSelected"
[fields]="contentFields" [fields]="contentFields"
[schema]="schema" [schema]="schema"
(unpublished)="unpublishContent(content)" (unpublishing)="unpublishContent(content)"
(published)="publishContent(content)" (publishing)="publishContent(content)"
(deleted)="deleteContent(content)"></tr> (deleting)="deleteContent(content)"></tr>
<tr class="spacer"></tr> <tr class="spacer"></tr>
</template> </template>
</tbody> </tbody>

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

@ -82,17 +82,17 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
} }
public ngOnInit() { public ngOnInit() {
this.messageUpdatedSubscription =
this.messageBus.of(ContentUpdated).subscribe(message => {
this.contentItems = this.contentItems.replaceAll(x => x.id === message.id, c => this.updateContent(c, true, message.data));
});
this.messageCreatedSubscription = this.messageCreatedSubscription =
this.messageBus.of(ContentCreated).subscribe(message => { this.messageBus.of(ContentCreated).subscribe(message => {
this.contentTotal++; this.contentTotal++;
this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data)); this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data));
}); });
this.messageUpdatedSubscription =
this.messageBus.of(ContentUpdated).subscribe(message => {
this.updateContents(message.id, true, message.data);
});
this.route.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => { this.route.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => {
this.languages = languages; this.languages = languages;
}); });
@ -117,7 +117,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.appName() this.appName()
.switchMap(app => this.contentsService.publishContent(app, this.schema.name, content.id)) .switchMap(app => this.contentsService.publishContent(app, this.schema.name, content.id))
.subscribe(() => { .subscribe(() => {
this.contentItems = this.contentItems.replaceAll(x => x.id === content.id, c => this.updateContent(c, true, content.data)); this.updateContents(content.id, true, content.data);
}, error => { }, error => {
this.notifyError(error); this.notifyError(error);
}); });
@ -127,7 +127,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.appName() this.appName()
.switchMap(app => this.contentsService.unpublishContent(app, this.schema.name, content.id)) .switchMap(app => this.contentsService.unpublishContent(app, this.schema.name, content.id))
.subscribe(() => { .subscribe(() => {
this.contentItems = this.contentItems.replaceAll(x => x.id === content.id, c => this.updateContent(c, false, content.data)); this.updateContents(content.id, false, content.data);
}, error => { }, error => {
this.notifyError(error); this.notifyError(error);
}); });
@ -204,6 +204,10 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
this.canGoPrev = this.currentPage > 0; this.canGoPrev = this.currentPage > 0;
} }
private updateContents(id: string, isPublished: boolean, data: any) {
this.contentItems = this.contentItems.replaceAll(x => x.id === id, c => this.updateContent(c, isPublished, data));
}
private createContent(id: string, data: any): ContentDto { private createContent(id: string, data: any): ContentDto {
const me = `subject:${this.authService.user!.id}`; const me = `subject:${this.authService.user!.id}`;

10
src/Squidex/app/features/schemas/pages/schema/field.component.html

@ -26,19 +26,19 @@
<i class="icon-dots"></i> <i class="icon-dots"></i>
</button> </button>
<div class="dropdown-menu" *sqxModalView="dropdown" closeAlways="true" [@fade]> <div class="dropdown-menu" *sqxModalView="dropdown" closeAlways="true" [@fade]>
<a class="dropdown-item" (click)="enabled.emit()" *ngIf="field.isDisabled"> <a class="dropdown-item" (click)="enabling.emit()" *ngIf="field.isDisabled">
Enable Enable
</a> </a>
<a class="dropdown-item" (click)="disabled.emit()" *ngIf="!field.isDisabled"> <a class="dropdown-item" (click)="disabling.emit()" *ngIf="!field.isDisabled">
Disable Disable
</a> </a>
<a class="dropdown-item" (click)="hidden.emit()" *ngIf="!field.isHidden"> <a class="dropdown-item" (click)="hiding.emit()" *ngIf="!field.isHidden">
Hide Hide
</a> </a>
<a class="dropdown-item" (click)="shown.emit()" *ngIf="field.isHidden"> <a class="dropdown-item" (click)="showing.emit()" *ngIf="field.isHidden">
Show Show
</a> </a>
<a class="dropdown-item" (click)="deleted.emit()"> <a class="dropdown-item" (click)="deleting.emit()">
Delete Delete
</a> </a>
</div> </div>

14
src/Squidex/app/features/schemas/pages/schema/field.component.ts

@ -30,22 +30,22 @@ export class FieldComponent implements OnInit {
public field: FieldDto; public field: FieldDto;
@Output() @Output()
public hidden = new EventEmitter<FieldDto>(); public hiding = new EventEmitter<FieldDto>();
@Output() @Output()
public shown = new EventEmitter<FieldDto>(); public showing = new EventEmitter<FieldDto>();
@Output() @Output()
public saved = new EventEmitter<FieldDto>(); public saving= new EventEmitter<FieldDto>();
@Output() @Output()
public enabled = new EventEmitter<FieldDto>(); public enabling = new EventEmitter<FieldDto>();
@Output() @Output()
public disabled = new EventEmitter<FieldDto>(); public disabling = new EventEmitter<FieldDto>();
@Output() @Output()
public deleted = new EventEmitter<FieldDto>(); public deleting = new EventEmitter<FieldDto>();
public isEditing: boolean = false; public isEditing: boolean = false;
public selectedTab = 0; public selectedTab = 0;
@ -93,7 +93,7 @@ export class FieldComponent implements OnInit {
this.field.isHidden, this.field.isHidden,
properties); properties);
this.saved.emit(field); this.saving.emit(field);
} }
} }

12
src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts

@ -59,6 +59,11 @@ export class SchemaEditFormComponent implements OnInit {
this.editForm.patchValue(this.schema); this.editForm.patchValue(this.schema);
} }
public cancel() {
this.reset();
this.cancelled.emit();
}
public saveSchema() { public saveSchema() {
this.editFormSubmitted = true; this.editFormSubmitted = true;
@ -78,13 +83,8 @@ export class SchemaEditFormComponent implements OnInit {
} }
} }
public reset() { private reset() {
this.editFormSubmitted = false; this.editFormSubmitted = false;
this.editForm.reset(); this.editForm.reset();
} }
public cancel() {
this.reset();
this.cancelled.emit();
}
} }

12
src/Squidex/app/features/schemas/pages/schema/schema-page.component.html

@ -28,12 +28,12 @@
<div class="panel-content"> <div class="panel-content">
<div *ngFor="let field of schemaFields"> <div *ngFor="let field of schemaFields">
<sqx-field [field]="field" <sqx-field [field]="field"
(disabled)="disableField(field)" (disabling)="disableField(field)"
(deleted)="deleteField(field)" (deleting)="deleteField(field)"
(enabled)="enableField(field)" (enabling)="enableField(field)"
(hidden)="hideField(field)" (showing)="showField(field)"
(saved)="saveField(field, $event)" (hiding)="hideField(field)"
(shown)="showField(field)"></sqx-field> (saving)="saveField(field, $event)"></sqx-field>
</div> </div>
<div class="table-items-footer"> <div class="table-items-footer">

4
src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts

@ -217,13 +217,13 @@ export class SchemaPageComponent extends AppComponentBase implements OnInit {
this.editSchemaDialog.hide(); this.editSchemaDialog.hide();
} }
public updateProperties(properties: SchemaPropertiesDto) { private updateProperties(properties: SchemaPropertiesDto) {
this.schemaProperties = properties; this.schemaProperties = properties;
this.notify(); this.notify();
} }
public updateField(field: FieldDto, newField: FieldDto) { private updateField(field: FieldDto, newField: FieldDto) {
this.schemaFields = this.schemaFields.replace(field, newField); this.schemaFields = this.schemaFields.replace(field, newField);
this.notify(); this.notify();

12
src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts

@ -62,6 +62,11 @@ export class SchemaFormComponent {
) { ) {
} }
public cancel() {
this.reset();
this.cancelled.emit();
}
public createSchema() { public createSchema() {
this.createFormSubmitted = true; this.createFormSubmitted = true;
@ -83,17 +88,12 @@ export class SchemaFormComponent {
} }
} }
public reset() { private reset() {
this.creationError = ''; this.creationError = '';
this.createForm.reset(); this.createForm.reset();
this.createFormSubmitted = false; this.createFormSubmitted = false;
} }
public cancel() {
this.reset();
this.cancelled.emit();
}
private createSchemaDto(id: string, name: string) { private createSchemaDto(id: string, name: string) {
const user = this.authService.user!.token; const user = this.authService.user!.token;
const now = DateTime.now(); const now = DateTime.now();

2
src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts

@ -73,7 +73,7 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
this.load(); this.load();
} }
public load() { private load() {
this.appName() this.appName()
.switchMap(app => this.schemasService.getSchemas(app).retry(2)) .switchMap(app => this.schemasService.getSchemas(app).retry(2))
.subscribe(dtos => { .subscribe(dtos => {

6
src/Squidex/app/features/settings/pages/clients/client.component.ts

@ -33,10 +33,10 @@ export class ClientComponent {
public token: AccessTokenDto; public token: AccessTokenDto;
@Output() @Output()
public renamed = new EventEmitter<string>(); public renaming = new EventEmitter<string>();
@Output() @Output()
public revoked = new EventEmitter(); public revoking = new EventEmitter();
@Input() @Input()
public client: AppClientDto; public client: AppClientDto;
@ -97,7 +97,7 @@ export class ClientComponent {
const newName = this.renameForm.get('name').value; const newName = this.renameForm.get('name').value;
if (newName !== this.clientName) { if (newName !== this.clientName) {
this.renamed.emit(newName); this.renaming.emit(newName);
} }
} finally { } finally {
this.isRenaming = false; this.isRenaming = false;

4
src/Squidex/app/features/settings/pages/clients/clients-page.component.html

@ -18,7 +18,9 @@
</div> </div>
<div *ngFor="let client of appClients"> <div *ngFor="let client of appClients">
<sqx-client [client]="client" [appName]="appName() | async" (renamed)="renameClient(client, $event)" (revoked)="revokeClient(client)"></sqx-client> <sqx-client [client]="client" [appName]="appName() | async"
(renaming)="renameClient(client, $event)"
(revoking)="revokeClient(client)"></sqx-client>
</div> </div>
<div class="table-items-footer"> <div class="table-items-footer">

10
src/Squidex/app/shared/components/app-form.component.ts

@ -50,6 +50,11 @@ export class AppFormComponent {
) { ) {
} }
public cancel() {
this.reset();
this.cancelled.emit();
}
public createApp() { public createApp() {
this.createFormSubmitted = true; this.createFormSubmitted = true;
@ -74,9 +79,4 @@ export class AppFormComponent {
this.createForm.enable(); this.createForm.enable();
this.createFormSubmitted = false; this.createFormSubmitted = false;
} }
public cancel() {
this.reset();
this.cancelled.emit();
}
} }
Loading…
Cancel
Save