Skip to content

Commit

Permalink
feat: Update collection model and store (#227)
Browse files Browse the repository at this point in the history
* fix: ellipsis on overflowing list items

* fix: fixed login page logo styling

* fix: added overflow hidden to content header title and subtitle

* fix: fixed scrolling

* chore: fixed lint issues

* feat: updated model WIP

* feat: started work on transformer WIP

* chore: fixed build errors WIP

* test: fixed tests in manage WIP

* feat: added basic transformers for collection objects WIP

* feat: support saving of objects WIP

* test: updated tests

* feat: implemented delete for objects

* fix: changed references, bnodes to literals

* chore: removed unnecessary properties

* chore: aligned model with form doc

* test: fixed low coverage

* test: upped coverage

* chore: remove commented onError

Co-authored-by: Wouter Janssens <wouter@digita.ai>
  • Loading branch information
lem-onade and wouteraj authored May 28, 2021
1 parent b65fc2c commit 28ce5b9
Show file tree
Hide file tree
Showing 21 changed files with 914 additions and 398 deletions.
2 changes: 1 addition & 1 deletion packages/solid-crs-client/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { login, handleIncomingRedirect, logout, fetch, getDefaultSession } from '@inrupt/solid-client-authn-browser';
export { getSolidDataset, getThing, getStringNoLocale, getStringNoLocaleAll, getUrl, getStringByLocaleAll, getStringWithLocale, getStringWithLocaleAll, getThingAll, getUrlAll, removeAll, removeThing, saveSolidDatasetAt, setThing, removeUrl, Thing, addStringWithLocale, addStringNoLocale, addUrl, addDatetime, getDatetime, createThing, asUrl, overwriteFile, deleteFile, ThingPersisted } from '@inrupt/solid-client';
export { getSolidDataset, getThing, getStringNoLocale, getStringNoLocaleAll, getUrl, getStringByLocaleAll, getStringWithLocale, getStringWithLocaleAll, getThingAll, getUrlAll, removeAll, removeThing, saveSolidDatasetAt, setThing, removeUrl, Thing, addStringWithLocale, addStringNoLocale, addUrl, addDatetime, getDatetime, createThing, asUrl, overwriteFile, deleteFile, ThingPersisted, getInteger, addInteger } from '@inrupt/solid-client';
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ObjectCardComponent extends LitElement {
*/
render() {

const timeAgo = getFormattedTimeAgo(this.object.updated, this.translator);
const timeAgo = getFormattedTimeAgo(+this.object.updated, this.translator);

return html`
<nde-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class DemoNDECardComponent extends LitElement {
image: 'https://images.unsplash.com/photo-1615390164801-cf2e70f32b53?ixid=MnwxMjA3fDB8MHxwcm9maWxlLXBhZ2V8M3x8fGVufDB8fHx8&ixlib=rb-1.2.1&w=1000&q=80',
subject: 'Wel Degelijk Geen Molen',
type: 'type',
updated: 1620216600000,
updated: '1620216600000',
collection: undefined,
} as CollectionObject;

const obj2 = { ...obj1, name: undefined } as CollectionObject;
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-crs-components/lib/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import '../node_modules/@netwerk-digitaal-erfgoed/solid-crs-theme/dist/style.css';

html {
height: 100%
height: 100%;
}

body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('CollectionObjectMemoryStore', () => {
image: null,
subject: null,
type: null,
updated: 0,
updated: undefined,
collection: 'collection-uri-1',
},
{
Expand All @@ -30,7 +30,7 @@ describe('CollectionObjectMemoryStore', () => {
image: null,
subject: null,
type: null,
updated: 0,
updated: undefined,
collection: 'collection-uri-1',
},
{
Expand All @@ -40,7 +40,7 @@ describe('CollectionObjectMemoryStore', () => {
image: null,
subject: null,
type: null,
updated: 0,
updated: undefined,
collection: 'collection-uri-2',
},
];
Expand All @@ -51,6 +51,8 @@ describe('CollectionObjectMemoryStore', () => {

service = new CollectionObjectMemoryStore(resources);

jest.clearAllMocks();

});

it('should be correctly instantiated', () => {
Expand Down Expand Up @@ -80,7 +82,7 @@ describe('CollectionObjectMemoryStore', () => {
image: null,
subject: null,
type: null,
updated: 0,
updated: undefined,
collection: 'collection-uri-1',
},
{
Expand All @@ -90,7 +92,7 @@ describe('CollectionObjectMemoryStore', () => {
image: null,
subject: null,
type: null,
updated: 0,
updated: undefined,
collection: 'collection-uri-1',
} ]);

Expand Down
133 changes: 124 additions & 9 deletions packages/solid-crs-core/lib/collections/collection-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@ import { Resource } from '../stores/resource';
* Represents a digitally archived objects.
*/
export interface CollectionObject extends Resource {

// IDENTIFICATION

/**
* The type of the object.
*/
type: string;

/**
* The name of the object.
*/
additionalType?: string;

/**
* The identifier of the object.
*/
identifier?: string;

/**
* The title of the object.
*/
name: string;

/**
Expand All @@ -15,27 +33,124 @@ export interface CollectionObject extends Resource {
description: string;

/**
* An image of the object.
* The collection to which the object belongs.
*/
image: string;
collection: string;

/**
* The maintainer of the object.
*/
maintainer?: string;

// CREATION

/**
* The creator of the object.
*/
creator?: string;

/**
* The creation date of the object.
*/
dateCreated?: string;

/**
* The creation location of the object.
*/
locationCreated?: string;

/**
* The material of the object.
*/
material?: string;

// REPRESENTATION

/**
* The subject of the object.
*/
subject: string;
subject?: string;

/**
* The type of the object.
* The location of the object.
*/
type: string;
location?: string;

/**
* The timestamp representing when the object was updated.
* The person of the object.
*/
updated: number;
person?: string;

/**
* The collection to which the object belongs.
* The organization of the object.
*/
collection: string;
organization?: string;

/**
* The event of the object.
*/
event?: string;

// ACQUISITION

// TBD

// DIMENSIONS

/**
* The height of the object.
*/
height?: number;

/**
* The height unit of the object.
*/
heightUnit?: string;

/**
* The width of the object.
*/
width?: number;

/**
* The width unit of the object.
*/
widthUnit?: string;

/**
* The depth of the object.
*/
depth?: number;

/**
* The depth unit of the object.
*/
depthUnit?: string;

/**
* The weight of the object.
*/
weight?: number;

/**
* The weight unit of the object.
*/
weightUnit?: string;

// OTHER

/**
* An image of the object.
*/
image: string;

/**
* A link to the digital representation of this object.
*/
mainEntityOfPage?: string;

/**
* The license of this object
*/
license?: string;
}
4 changes: 4 additions & 0 deletions packages/solid-crs-core/lib/stores/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ export interface Resource {
* The identifier of the resource.
*/
uri: string;
/**
* When the resource was last updated
*/
updated?: string;
}
4 changes: 2 additions & 2 deletions packages/solid-crs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"statements": 87.56,
"lines": 87.5,
"functions": 89.19
}
}
},
"coveragePathIgnorePatterns": [
"<rootDir>/dist/",
Expand All @@ -74,4 +74,4 @@
"displayName": "core",
"preset": "@digita-ai/jest-config"
}
}
}
10 changes: 9 additions & 1 deletion packages/solid-crs-manage/lib/app-root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,20 @@ export class AppRootComponent extends RxLitElement {
new CollectionSolidStore(),
new CollectionObjectSolidStore(),
{
uri: null,
uri: undefined,
name: this.translator.translate('nde.features.collections.new-collection-name'),
description: this.translator.translate('nde.features.collections.new-collection-description'),
objectsUri: undefined,
distribution: undefined,
},
{
uri: undefined,
name: this.translator.translate('nde.features.object.new-object-name'),
description: this.translator.translate('nde.features.object.new-object-description'),
collection: undefined,
type: undefined,
image: undefined,
}
)).withContext({
alerts: [],
}), { devTools: true },
Expand Down
9 changes: 5 additions & 4 deletions packages/solid-crs-manage/lib/app.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { DoneInvokeEvent } from 'xstate';
import { assign, choose, send } from 'xstate/lib/actions';
import { AppContext } from './app.machine';
import { SolidSession } from './common/solid/solid-session';
import { ClickedDeleteEvent, SavedCollectionEvent, SelectedCollectionEvent } from 'features/collection/collection.events';
import { ClickedDeleteCollectionEvent, SavedCollectionEvent, SelectedCollectionEvent } from 'features/collection/collection.events';
import { SearchUpdatedEvent } from 'features/search/search.events';
import { SelectedObjectEvent } from 'features/object/object.events';
import { ClickedDeleteObjectEvent, SelectedObjectEvent } from 'features/object/object.events';

/**
* Event references for the application root, with readable log format.
Expand Down Expand Up @@ -91,12 +91,13 @@ export type AppEvent =
| DismissAlertEvent
| AddAlertEvent
| SelectedCollectionEvent
| ClickedDeleteEvent
| ClickedDeleteCollectionEvent
| ClickedCreateCollectionEvent
| CollectionsLoadedEvent
| SearchUpdatedEvent
| SavedCollectionEvent
| SelectedObjectEvent;
| SelectedObjectEvent
| ClickedDeleteObjectEvent;

/**
* Actions for the alerts component.
Expand Down
10 changes: 6 additions & 4 deletions packages/solid-crs-manage/lib/app.machine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alert, FormActors, formMachine, FormValidatorResult, State } from '@netwerk-digitaal-erfgoed/solid-crs-components';
import { Collection, CollectionObjectStore, CollectionStore } from '@netwerk-digitaal-erfgoed/solid-crs-core';
import { Collection, CollectionObjectStore, CollectionStore, CollectionObject } from '@netwerk-digitaal-erfgoed/solid-crs-core';
import { createMachine } from 'xstate';
import { assign, forwardTo, log, send } from 'xstate/lib/actions';
import { Observable, of } from 'rxjs';
Expand Down Expand Up @@ -106,7 +106,8 @@ export const appMachine = (
solid: SolidService,
collectionStore: CollectionStore,
objectStore: CollectionObjectStore,
template: Collection,
collectionTemplate: Collection,
objectTemplate: CollectionObject,
) =>
createMachine<AppContext, AppEvent, State<AppStates, AppContext>>({
id: AppActors.APP_MACHINE,
Expand Down Expand Up @@ -167,7 +168,7 @@ export const appMachine = (
invoke: [
{
id: AppActors.COLLECTION_MACHINE,
src: collectionMachine(collectionStore, objectStore),
src: collectionMachine(collectionStore, objectStore, objectTemplate),
data: (context, event) => ({
collection: context.selected,
}),
Expand Down Expand Up @@ -355,6 +356,7 @@ export const appMachine = (
[AppEvents.CLICKED_CREATE_COLLECTION]: AppDataStates.CREATING,
[AppEvents.LOGGED_IN]: AppDataStates.REFRESHING,
[CollectionEvents.CLICKED_DELETE]: AppDataStates.REFRESHING,
[ObjectEvents.CLICKED_DELETE]: AppDataStates.REFRESHING,
[CollectionEvents.SAVED_COLLECTION]: AppDataStates.REFRESHING,
},
},
Expand Down Expand Up @@ -397,7 +399,7 @@ export const appMachine = (
/**
* Save collection to the store.
*/
src: () => collectionStore.save(template), // TODO: Update
src: () => collectionStore.save(collectionTemplate), // TODO: Update
onDone: {
target: AppDataStates.IDLE,
actions: [
Expand Down
Loading

0 comments on commit 28ce5b9

Please sign in to comment.