Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface CedarMetadataDataTemplateJsonApi {
schema_name: string;
cedar_id: string;
template: CedarTemplate;
is_for_collections: boolean;
};
}

Expand Down Expand Up @@ -76,6 +77,7 @@ export interface CedarMetadataTemplate {
schema_name: string;
cedar_id: string;
template: CedarTemplate;
is_for_collections: boolean;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('AddMetadataComponent', () => {
MockProvider(ToastService, toastService),
provideMockStore({
signals: [
{ selector: MetadataSelectors.getCedarTemplates, value: mockCedarTemplates },
{ selector: MetadataSelectors.getCedarTemplatesExcludingCollections, value: mockCedarTemplates },
{ selector: MetadataSelectors.getCedarRecords, value: mockCedarRecords },
{ selector: MetadataSelectors.getCedarTemplatesLoading, value: false },
{ selector: MetadataSelectors.getCedarRecord, value: { data: mockRecord } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class AddMetadataComponent implements OnInit {
selectedTemplate: CedarMetadataDataTemplateJsonApi | null = null;
existingRecord: CedarMetadataRecordData | null = null;

readonly cedarTemplates = select(MetadataSelectors.getCedarTemplates);
readonly cedarTemplates = select(MetadataSelectors.getCedarTemplatesExcludingCollections);
readonly cedarRecords = select(MetadataSelectors.getCedarRecords);
readonly cedarTemplatesLoading = select(MetadataSelectors.getCedarTemplatesLoading);
readonly cedarRecord = select(MetadataSelectors.getCedarRecord);
Expand Down Expand Up @@ -136,7 +136,7 @@ export class AddMetadataComponent implements OnInit {
if (!templates?.links?.next) {
return;
}
this.actions.getCedarTemplates(templates.links.next);
this.actions.getCedarTemplates({ url: templates.links.next });
}

hasNextPage(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/metadata/store/metadata.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class GetFundersList {

export class GetCedarMetadataTemplates {
static readonly type = '[Metadata] Get Cedar Metadata Templates';
constructor(public url?: string) {}
constructor(public options: { url?: string } = {}) {}
Comment thread
adlius marked this conversation as resolved.
Outdated
}

export class GetCedarMetadataRecords {
Expand Down
10 changes: 10 additions & 0 deletions src/app/features/metadata/store/metadata.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export class MetadataSelectors {
return state.cedarTemplates.data;
}

@Selector([MetadataState])
static getCedarTemplatesExcludingCollections(state: MetadataStateModel) {
const templates = state.cedarTemplates.data;
if (!templates) return null;
return {
...templates,
data: templates.data.filter((t) => !t.attributes.is_for_collections),
};
}

@Selector([MetadataState])
static getCedarTemplatesLoading(state: MetadataStateModel) {
return state.cedarTemplates.isLoading;
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/metadata/store/metadata.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class MetadataState {
},
});

return this.metadataService.getMetadataCedarTemplates(action.url).pipe(
return this.metadataService.getMetadataCedarTemplates(action.options.url).pipe(
tap({
next: (response) => {
ctx.patchState({
Expand Down
1 change: 1 addition & 0 deletions src/testing/data/collections/cedar-metadata.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const MOCK_CEDAR_TEMPLATE: CedarMetadataDataTemplateJsonApi = {
properties: {},
_ui: { order: [], propertyLabels: {}, propertyDescriptions: {} },
},
is_for_collections: false,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export const CEDAR_METADATA_DATA_TEMPLATE_JSON_API_MOCK: CedarMetadataTemplate =
},
},
},
is_for_collections: false,
},
};
Loading