Browse Source

Fix schema categories.

pull/372/head
Sebastian Stehle 7 years ago
parent
commit
ef1ba770d6
  1. 2
      src/Squidex/app/shared/components/schema-category.component.html
  2. 8
      src/Squidex/app/shared/components/schema-category.component.ts
  3. 2
      src/Squidex/app/shared/services/schemas.service.spec.ts
  4. 2
      src/Squidex/app/shared/services/schemas.service.ts

2
src/Squidex/app/shared/components/schema-category.component.html

@ -8,7 +8,7 @@
<h3>{{snapshot.displayName}} ({{snapshot.schemasFiltered.length}})</h3> <h3>{{snapshot.displayName}} ({{snapshot.schemasFiltered.length}})</h3>
<button type="button" class="btn btn-sm btn-text-secondary float-right" *ngIf="snapshot.schemasForCategory.length === 0 && !forContent" (click)="emitRemove()"> <button type="button" class="btn btn-sm btn-text-secondary float-right" *ngIf="snapshot.schemasForCategory.length === 0 && snapshot.isDeletable && !forContent" (click)="emitRemove()">
<i class="icon-bin2"></i> <i class="icon-bin2"></i>
</button> </button>
</div> </div>

8
src/Squidex/app/shared/components/schema-category.component.ts

@ -24,6 +24,8 @@ interface State {
schemasFiltered: ImmutableArray<SchemaDto>; schemasFiltered: ImmutableArray<SchemaDto>;
schemasForCategory: ImmutableArray<SchemaDto>; schemasForCategory: ImmutableArray<SchemaDto>;
isDeletable: boolean;
isOpen: boolean; isOpen: boolean;
} }
@ -64,6 +66,7 @@ export class SchemaCategoryComponent extends StatefulComponent<State> implements
private readonly schemasState: SchemasState private readonly schemasState: SchemasState
) { ) {
super(changeDetector, { super(changeDetector, {
isDeletable: true,
schemasFiltered: ImmutableArray.empty(), schemasFiltered: ImmutableArray.empty(),
schemasForCategory: ImmutableArray.empty(), schemasForCategory: ImmutableArray.empty(),
isOpen: true isOpen: true
@ -104,12 +107,15 @@ export class SchemaCategoryComponent extends StatefulComponent<State> implements
if (changes['name']) { if (changes['name']) {
let displayName = 'Schemas'; let displayName = 'Schemas';
let isDeletable = true;
if (this.name && this.name.length > 0) { if (this.name && this.name.length > 0) {
displayName = this.name; displayName = this.name;
} else {
isDeletable = false;
} }
this.next(s => ({ ...s, displayName })); this.next(s => ({ ...s, isDeletable, displayName }));
} }
} }

2
src/Squidex/app/shared/services/schemas.service.spec.ts

@ -205,7 +205,7 @@ describe('SchemasService', () => {
const resource: Resource = { const resource: Resource = {
_links: { _links: {
updateCategory: { method: 'PUT', href: '/api/apps/my-app/schemas/my-schema/category' } ['update/category']: { method: 'PUT', href: '/api/apps/my-app/schemas/my-schema/category' }
} }
}; };

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

@ -310,7 +310,7 @@ export class SchemasService {
} }
public putCategory(appName: string, resource: Resource, dto: UpdateSchemaCategoryDto, version: Version): Observable<SchemaDetailsDto> { public putCategory(appName: string, resource: Resource, dto: UpdateSchemaCategoryDto, version: Version): Observable<SchemaDetailsDto> {
const link = resource._links['updateCategory']; const link = resource._links['update/category'];
const url = this.apiUrl.buildUrl(link.href); const url = this.apiUrl.buildUrl(link.href);

Loading…
Cancel
Save