-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Goals -> Limitations feature
- Loading branch information
Showing
10 changed files
with
122 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Limit from '~/domain/Limit.mjs'; | ||
import { LocalStorageRepository } from './LocalStorageRepository.mjs'; | ||
import LimitToJsonMapper from '~/mappers/LimitToJsonMapper.mjs'; | ||
import pkg from '~/../package.json' with { type: 'json' }; | ||
|
||
export default class UseCaseRepository extends LocalStorageRepository<Limit> { | ||
constructor() { super('limits', new LimitToJsonMapper(pkg.version)); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Properties } from '~/types/Properties.mjs'; | ||
import Requirement from './Requirement.mjs'; | ||
|
||
/** | ||
* A Limit is a requirement describing a property that is out-of-scope. | ||
* Example: "Providing an interface to the user to change the color of the background is out-of-scope." | ||
*/ | ||
export default class Limit extends Requirement { | ||
constructor(properties: Properties<Limit>) { | ||
super(properties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Limit from '~/domain/Limit.mjs'; | ||
import RequirementToJsonMapper, { type RequirementJson } from './RequirementToJsonMapper.mjs'; | ||
|
||
export interface LimitJson extends RequirementJson { } | ||
|
||
export default class BehaviorToJsonMapper extends RequirementToJsonMapper { | ||
override mapFrom(target: LimitJson): Limit { | ||
const version = target.serializationVersion ?? '{undefined}'; | ||
|
||
if (version.startsWith('0.3.')) | ||
return new Limit(target); | ||
|
||
throw new Error(`Unsupported serialization version: ${version}`); | ||
} | ||
override mapTo(source: Limit): LimitJson { | ||
return super.mapTo(source); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import Limit from '~/domain/Limit.mjs'; | ||
import type Goals from '~/domain/Goals.mjs'; | ||
import GoalsRepository from '~/data/GoalsRepository.mjs'; | ||
import LimitRepository from '~/data/LimitRepository.mjs'; | ||
import html from '~/presentation/lib/html.mjs'; | ||
import { DataTable } from '~/presentation/components/DataTable.mjs'; | ||
import { SlugPage } from '../SlugPage.mjs'; | ||
|
||
const { p } = html; | ||
|
||
export class Limitations extends SlugPage { | ||
static { | ||
customElements.define('x-limitations-page', this); | ||
} | ||
|
||
#goalsRepository = new GoalsRepository(); | ||
#limitRepository = new LimitRepository(); | ||
#goals?: Goals; | ||
|
||
constructor() { | ||
super({ title: 'Limitations' }, [ | ||
p([ | ||
`Limitations are the constraints on functionality. | ||
They describe What that is out-of-scope and excluded. | ||
Example: "Providing an interface to the user to change | ||
the color of the background is out-of-scope." | ||
` | ||
]) | ||
]); | ||
|
||
const dataTable = new DataTable<Limit>({ | ||
columns: { | ||
id: { headerText: 'ID', readonly: true, formType: 'hidden' }, | ||
statement: { headerText: 'Statement', required: true, formType: 'text' } | ||
}, | ||
select: async () => { | ||
if (!this.#goals) | ||
return []; | ||
|
||
return await this.#limitRepository.getAll(l => this.#goals!.limits.includes(l.id)); | ||
}, | ||
onCreate: async item => { | ||
const limit = new Limit({ ...item, id: self.crypto.randomUUID() }); | ||
await this.#limitRepository.add(limit); | ||
this.#goals!.limits.push(limit.id); | ||
await this.#goalsRepository.update(this.#goals!); | ||
}, | ||
onUpdate: async item => { | ||
const limit = (await this.#limitRepository.get(item.id))!; | ||
limit.statement = item.statement; | ||
await this.#limitRepository.update(limit); | ||
}, | ||
onDelete: async id => { | ||
await this.#limitRepository.delete(id); | ||
this.#goals!.limits = this.#goals!.limits.filter(x => x !== id); | ||
await this.#goalsRepository.update(this.#goals!); | ||
} | ||
}); | ||
this.append(dataTable); | ||
|
||
this.#goalsRepository.addEventListener('update', () => dataTable.renderData()); | ||
this.#limitRepository.addEventListener('update', () => dataTable.renderData()); | ||
this.#goalsRepository.getBySlug(this.slug).then(goals => { | ||
this.#goals = goals; | ||
dataTable.renderData(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters