@lblod/ember-rdfa-editor-lblod-plugins 14.0.0 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/addon/components/variable-plugin/date/edit.hbs +12 -10
- package/addon/components/variable-plugin/date/edit.ts +7 -0
- package/addon/plugins/standard-template-plugin/index.ts +2 -0
- package/addon/plugins/standard-template-plugin/utils/instantiate-uuids.ts +5 -13
- package/addon/plugins/variable-plugin/utils/address-helpers.ts +6 -4
- package/addon/plugins/variable-plugin/variables/date.ts +15 -2
- package/addon/utils/memoize.ts +11 -3
- package/components/variable-plugin/address/edit.d.ts +1 -1
- package/components/variable-plugin/date/edit.d.ts +1 -0
- package/package.json +2 -2
- package/plugins/standard-template-plugin/index.d.ts +1 -0
- package/plugins/variable-plugin/utils/address-helpers.d.ts +1 -1
- package/utils/memoize.d.ts +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @lblod/ember-rdfa-editor-lblod-plugins
|
|
2
2
|
|
|
3
|
+
## 14.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#315](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/315) [`01163d8`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/01163d8d45b801a50728b9aeabaf0e52a1cf9a33) Thanks [@piemonkey](https://github.com/piemonkey)! - Export standard-template-plugin's uuid instantiation function
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#317](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/317) [`1d28bc9`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/1d28bc9b9b0e07e8eb5698988dfe0e3dd946c2a3) Thanks [@dkozickis](https://github.com/dkozickis)! - GN-4538: Display correctly that there are no streets when searching in the address plugin
|
|
12
|
+
|
|
13
|
+
- [#316](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/316) [`e109035`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/e109035809df341ede0a03fb0b146909883903ef) Thanks [@x-m-el](https://github.com/x-m-el)! - - Bugfix: `allowCustomFormat` for rdfa-date variable will now disable custom formats if set to false.
|
|
14
|
+
- No changes for old documents: date variables in old documents will allow custom formats, which is the default.
|
|
15
|
+
|
|
3
16
|
## 14.0.0
|
|
4
17
|
|
|
5
18
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -695,7 +695,7 @@ get dateOptions(){
|
|
|
695
695
|
- `key`: A **unique** identifier used for identification in the internal code.
|
|
696
696
|
- `dateFormat`: The date format used when this is selected.
|
|
697
697
|
- `dateTimeFormat`: The datetime format to use when this is selected. Used when the user selects "Include time".
|
|
698
|
-
- `allowCustomFormat`: true
|
|
698
|
+
- `allowCustomFormat`: true by default, determines if the option to insert a fully custom format is available for newly created date nodes.
|
|
699
699
|
|
|
700
700
|
The syntax of formats can be found at [date-fns](https://date-fns.org/v2.29.3/docs/format).
|
|
701
701
|
|
|
@@ -56,16 +56,18 @@
|
|
|
56
56
|
/>
|
|
57
57
|
</AuFormRow>
|
|
58
58
|
{{/each}}
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
{{#if this.isCustomAllowed}}
|
|
60
|
+
<AuFormRow>
|
|
61
|
+
<AuControlRadio
|
|
62
|
+
@label={{t "date-plugin.card.custom-date" }}
|
|
63
|
+
@identifier="custom"
|
|
64
|
+
@name="dateFormat"
|
|
65
|
+
@value="custom"
|
|
66
|
+
checked={{eq this.dateFormatType "custom"}}
|
|
67
|
+
@onChange={{this.setDateFormatFromKey}}
|
|
68
|
+
/>
|
|
69
|
+
</AuFormRow>
|
|
70
|
+
{{/if}}
|
|
69
71
|
{{#if (eq this.dateFormatType "custom")}}
|
|
70
72
|
<AuFormRow @alignment="post">
|
|
71
73
|
<AuButton @skin="secondary" @icon="info-circle"
|
|
@@ -125,6 +125,13 @@ export default class DateEditComponent extends Component<Args> {
|
|
|
125
125
|
return unwrapOr(false, this.selectedDateNode?.attrs.custom as boolean);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
get isCustomAllowed(): boolean {
|
|
129
|
+
return unwrapOr(
|
|
130
|
+
true,
|
|
131
|
+
this.selectedDateNode?.attrs.customAllowed as boolean,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
128
135
|
get dateFormatType(): string {
|
|
129
136
|
if (this.isCustom) {
|
|
130
137
|
return 'custom';
|
|
@@ -17,7 +17,8 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
export default function instantiateUuids(templateString: string) {
|
|
20
|
-
|
|
20
|
+
// We're not interested in the args in this case, we just use them to memoize
|
|
21
|
+
const generateBoundUuid = memoize((..._args: unknown[]) => uuidv4());
|
|
21
22
|
|
|
22
23
|
const determineFunction = (string: string) => {
|
|
23
24
|
switch (string) {
|
|
@@ -31,18 +32,9 @@ export default function instantiateUuids(templateString: string) {
|
|
|
31
32
|
};
|
|
32
33
|
return templateString.replace(
|
|
33
34
|
/\$\{(generateUuid|generateBoundUuid)\(([^()]*)\)\}/g,
|
|
34
|
-
(
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
if (match) {
|
|
39
|
-
const functionName = match[1];
|
|
40
|
-
const functionArgs = match[2];
|
|
41
|
-
const func = determineFunction(functionName);
|
|
42
|
-
return functionArgs ? func(functionArgs) : func();
|
|
43
|
-
} else {
|
|
44
|
-
return string;
|
|
45
|
-
}
|
|
35
|
+
(_match, functionName, functionArgs) => {
|
|
36
|
+
const func = determineFunction(functionName);
|
|
37
|
+
return functionArgs ? func(functionArgs) : func();
|
|
46
38
|
},
|
|
47
39
|
);
|
|
48
40
|
}
|
|
@@ -22,7 +22,7 @@ type StreetSearchResult = {
|
|
|
22
22
|
gemeente: {
|
|
23
23
|
gemeentenaam: { geografischeNaam: { spelling: string } };
|
|
24
24
|
};
|
|
25
|
-
straatnaam
|
|
25
|
+
straatnaam?: {
|
|
26
26
|
straatnaam: {
|
|
27
27
|
geografischeNaam: { spelling: string };
|
|
28
28
|
};
|
|
@@ -135,9 +135,11 @@ export async function fetchStreets(term: string, municipality: string) {
|
|
|
135
135
|
});
|
|
136
136
|
if (result.ok) {
|
|
137
137
|
const jsonResult = (await result.json()) as StreetSearchResult;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
|
|
139
|
+
const streetnames = jsonResult.adresMatches
|
|
140
|
+
.map((entry) => entry.straatnaam?.straatnaam.geografischeNaam.spelling)
|
|
141
|
+
.filter(Boolean);
|
|
142
|
+
|
|
141
143
|
return streetnames;
|
|
142
144
|
} else {
|
|
143
145
|
throw new AddressError({
|
|
@@ -65,6 +65,7 @@ const parseDOM = [
|
|
|
65
65
|
onlyDate,
|
|
66
66
|
format: node.dataset.format,
|
|
67
67
|
custom: node.dataset.custom === 'true',
|
|
68
|
+
customAllowed: node.dataset.customAllowed !== 'false',
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
return false;
|
|
@@ -96,6 +97,7 @@ const parseDOM = [
|
|
|
96
97
|
value: value,
|
|
97
98
|
format: format,
|
|
98
99
|
custom: dateNode?.dataset.custom === 'true',
|
|
100
|
+
customAllowed: dateNode?.dataset.customAllowed !== 'false',
|
|
99
101
|
label,
|
|
100
102
|
};
|
|
101
103
|
}
|
|
@@ -108,8 +110,15 @@ const parseDOM = [
|
|
|
108
110
|
const serialize = (node: PNode, state: EditorState) => {
|
|
109
111
|
const t = getTranslationFunction(state);
|
|
110
112
|
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
+
const {
|
|
114
|
+
value,
|
|
115
|
+
onlyDate,
|
|
116
|
+
format,
|
|
117
|
+
mappingResource,
|
|
118
|
+
custom,
|
|
119
|
+
customAllowed,
|
|
120
|
+
label,
|
|
121
|
+
} = node.attrs;
|
|
113
122
|
const datatype = onlyDate ? XSD('date') : XSD('dateTime');
|
|
114
123
|
let humanReadableDate: string;
|
|
115
124
|
if (value) {
|
|
@@ -130,6 +139,7 @@ const serialize = (node: PNode, state: EditorState) => {
|
|
|
130
139
|
datatype: datatype.prefixed,
|
|
131
140
|
'data-format': format as string,
|
|
132
141
|
'data-custom': custom ? 'true' : 'false',
|
|
142
|
+
'data-custom-allowed': customAllowed ? 'true' : 'false',
|
|
133
143
|
...(!!value && { content: value as string }),
|
|
134
144
|
};
|
|
135
145
|
return mappingSpan(
|
|
@@ -164,6 +174,9 @@ const emberNodeConfig = (options: DateOptions): EmberNodeConfig => ({
|
|
|
164
174
|
custom: {
|
|
165
175
|
default: false,
|
|
166
176
|
},
|
|
177
|
+
customAllowed: {
|
|
178
|
+
default: options.allowCustomFormat,
|
|
179
|
+
},
|
|
167
180
|
label: { default: null },
|
|
168
181
|
},
|
|
169
182
|
// TODO: is this property still required?
|
package/addon/utils/memoize.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Return memoized version of the passed function.
|
|
3
|
+
* Memoization is done on the JSON stringified arguments, passing no args, undefined, or any number
|
|
4
|
+
* of only undefined arguments does not do any caching.
|
|
5
|
+
*/
|
|
6
|
+
export default function memoize<T>(func: (...a: unknown[]) => T) {
|
|
7
|
+
const cache: Record<string, T> = {};
|
|
3
8
|
return (...args: unknown[]) => {
|
|
9
|
+
if (args.length === 0 || args.every((arg) => arg === undefined)) {
|
|
10
|
+
return func(...args);
|
|
11
|
+
}
|
|
4
12
|
const serializedArgs = JSON.stringify(args);
|
|
5
|
-
cache[serializedArgs] = cache[serializedArgs] || func(args);
|
|
13
|
+
cache[serializedArgs] = cache[serializedArgs] || func(...args);
|
|
6
14
|
return cache[serializedArgs];
|
|
7
15
|
};
|
|
8
16
|
}
|
|
@@ -43,6 +43,6 @@ export default class AddressEditComponent extends Component<Args> {
|
|
|
43
43
|
updateBusnumber(event: InputEvent): void;
|
|
44
44
|
get controller(): SayController;
|
|
45
45
|
searchMunicipality: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (term: string) => Promise<string[]>>;
|
|
46
|
-
searchStreet: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (term: string) => Promise<string[]>>;
|
|
46
|
+
searchStreet: import("ember-concurrency").TaskForAsyncTaskFunction<unknown, (term: string) => Promise<(string | undefined)[]>>;
|
|
47
47
|
}
|
|
48
48
|
export {};
|
|
@@ -25,6 +25,7 @@ export default class DateEditComponent extends Component<Args> {
|
|
|
25
25
|
get documentDateFormat(): Option<string>;
|
|
26
26
|
get documentDateFormatType(): Option<DateFormat>;
|
|
27
27
|
get isCustom(): boolean;
|
|
28
|
+
get isCustomAllowed(): boolean;
|
|
28
29
|
get dateFormatType(): string;
|
|
29
30
|
get customDateFormatError(): ValidationError | null;
|
|
30
31
|
get humanError(): string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lblod/ember-rdfa-editor-lblod-plugins",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"ember-template-lint": "^4.16.1",
|
|
127
127
|
"ember-try": "^2.0.0",
|
|
128
128
|
"eslint": "^8.44.0",
|
|
129
|
-
"eslint-config-prettier": "^
|
|
129
|
+
"eslint-config-prettier": "^9.0.0",
|
|
130
130
|
"eslint-plugin-ember": "^11.1.0",
|
|
131
131
|
"eslint-plugin-node": "^11.1.0",
|
|
132
132
|
"eslint-plugin-prettier": "^5.0.0",
|
|
@@ -15,7 +15,7 @@ export declare class AddressError extends Error {
|
|
|
15
15
|
}
|
|
16
16
|
export declare const replaceAccents: (string: string) => string;
|
|
17
17
|
export declare function fetchMunicipalities(term: string): Promise<string[]>;
|
|
18
|
-
export declare function fetchStreets(term: string, municipality: string): Promise<string[]>;
|
|
18
|
+
export declare function fetchStreets(term: string, municipality: string): Promise<(string | undefined)[]>;
|
|
19
19
|
type StreetInfo = {
|
|
20
20
|
municipality: string;
|
|
21
21
|
street: string;
|
package/utils/memoize.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Return memoized version of the passed function.
|
|
3
|
+
* Memoization is done on the JSON stringified arguments, passing no args, undefined, or any number
|
|
4
|
+
* of only undefined arguments does not do any caching.
|
|
5
|
+
*/
|
|
6
|
+
export default function memoize<T>(func: (...a: unknown[]) => T): (...args: unknown[]) => T;
|