Browse Source

Better fix for Categories.

pull/372/head
Sebastian Stehle 7 years ago
parent
commit
6c2a75bf13
  1. 2
      src/Squidex/app/shared/components/schema-category.component.html
  2. 8
      src/Squidex/app/shared/components/schema-category.component.ts
  3. 6
      src/Squidex/app/shared/state/schemas.state.ts

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

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

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

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

6
src/Squidex/app/shared/state/schemas.state.ts

@ -140,7 +140,9 @@ export class SchemasState extends State<Snapshot> {
this.next(s => {
const schemas = s.schemas.push(created).sortByStringAsc(x => x.displayName);
return { ...s, schemas };
const categories = buildCategories(s.categories, schemas);
return { ...s, schemas, categories };
});
}),
shareSubscribed(this.dialogs, { silent: true }));
@ -343,8 +345,6 @@ function buildCategories(categories: { [name: string]: boolean }, schemas?: Sche
}
}
categories[''] = true;
return categories;
}

Loading…
Cancel
Save