@things-factory/personalization 7.0.1-alpha.64 → 7.0.1-alpha.69
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/client/page-preference-provider-impl.ts +28 -4
- package/client/types.ts +4 -3
- package/dist-client/page-preference-provider-impl.d.ts +5 -12
- package/dist-client/page-preference-provider-impl.js +19 -0
- package/dist-client/page-preference-provider-impl.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/types.d.ts +4 -11
- package/dist-client/types.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -7,15 +7,15 @@ import { PagePreferenceProvider } from './types'
|
|
|
7
7
|
export class PagePreferenceProviderImpl implements PagePreferenceProvider {
|
|
8
8
|
public page?: string
|
|
9
9
|
public element?: string
|
|
10
|
-
public preference?:
|
|
10
|
+
public preference?: any
|
|
11
11
|
|
|
12
|
-
constructor(page: string, element: string, preference?:
|
|
12
|
+
constructor(page: string, element: string, preference?: any) {
|
|
13
13
|
this.page = page
|
|
14
14
|
this.element = element
|
|
15
15
|
this.preference = preference
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async load(): Promise<
|
|
18
|
+
async load(): Promise<any> {
|
|
19
19
|
const response = await client.query({
|
|
20
20
|
query: gql`
|
|
21
21
|
query ($page: String!, $element: String!) {
|
|
@@ -36,7 +36,7 @@ export class PagePreferenceProviderImpl implements PagePreferenceProvider {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
async save(preference:
|
|
39
|
+
async save(preference: any): Promise<any> {
|
|
40
40
|
const response = await client.mutate({
|
|
41
41
|
mutation: gql`
|
|
42
42
|
mutation ($page: String!, $element: String!, $preference: Object!) {
|
|
@@ -52,6 +52,30 @@ export class PagePreferenceProviderImpl implements PagePreferenceProvider {
|
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
+
if (!response.errors) {
|
|
56
|
+
document.dispatchEvent(
|
|
57
|
+
new CustomEvent('notify', {
|
|
58
|
+
detail: { message: i18next.t('text.updated_successfully'), option: { timer: 3000 } }
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
return response.data.updateMyPagePreference.preference
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async reset(): Promise<void> {
|
|
67
|
+
const response = await client.mutate({
|
|
68
|
+
mutation: gql`
|
|
69
|
+
mutation ($page: String!, $element: String!) {
|
|
70
|
+
deleteMyPagePreference(page: $page, element: $element)
|
|
71
|
+
}
|
|
72
|
+
`,
|
|
73
|
+
variables: {
|
|
74
|
+
page: this.page,
|
|
75
|
+
element: this.element
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
55
79
|
if (!response.errors) {
|
|
56
80
|
document.dispatchEvent(
|
|
57
81
|
new CustomEvent('notify', {
|
package/client/types.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export interface PagePreferenceProvider {
|
|
2
2
|
page?: string
|
|
3
3
|
element?: string
|
|
4
|
-
preference?:
|
|
4
|
+
preference?: any
|
|
5
5
|
|
|
6
|
-
load: () =>
|
|
7
|
-
save: (preference:
|
|
6
|
+
load: () => any | Promise<any>
|
|
7
|
+
save: (preference: any) => any | Promise<any>
|
|
8
|
+
reset: () => void | Promise<void>
|
|
8
9
|
}
|
|
@@ -2,16 +2,9 @@ import { PagePreferenceProvider } from './types';
|
|
|
2
2
|
export declare class PagePreferenceProviderImpl implements PagePreferenceProvider {
|
|
3
3
|
page?: string;
|
|
4
4
|
element?: string;
|
|
5
|
-
preference?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
load(): Promise<{
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
} | undefined>;
|
|
14
|
-
save(preference: {
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}): Promise<void>;
|
|
5
|
+
preference?: any;
|
|
6
|
+
constructor(page: string, element: string, preference?: any);
|
|
7
|
+
load(): Promise<any>;
|
|
8
|
+
save(preference: any): Promise<any>;
|
|
9
|
+
reset(): Promise<void>;
|
|
17
10
|
}
|
|
@@ -42,6 +42,25 @@ export class PagePreferenceProviderImpl {
|
|
|
42
42
|
preference
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
+
if (!response.errors) {
|
|
46
|
+
document.dispatchEvent(new CustomEvent('notify', {
|
|
47
|
+
detail: { message: i18next.t('text.updated_successfully'), option: { timer: 3000 } }
|
|
48
|
+
}));
|
|
49
|
+
return response.data.updateMyPagePreference.preference;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async reset() {
|
|
53
|
+
const response = await client.mutate({
|
|
54
|
+
mutation: gql `
|
|
55
|
+
mutation ($page: String!, $element: String!) {
|
|
56
|
+
deleteMyPagePreference(page: $page, element: $element)
|
|
57
|
+
}
|
|
58
|
+
`,
|
|
59
|
+
variables: {
|
|
60
|
+
page: this.page,
|
|
61
|
+
element: this.element
|
|
62
|
+
}
|
|
63
|
+
});
|
|
45
64
|
if (!response.errors) {
|
|
46
65
|
document.dispatchEvent(new CustomEvent('notify', {
|
|
47
66
|
detail: { message: i18next.t('text.updated_successfully'), option: { timer: 3000 } }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-preference-provider-impl.js","sourceRoot":"","sources":["../client/page-preference-provider-impl.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,MAAM,OAAO,0BAA0B;IAKrC,YAAY,IAAY,EAAE,OAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"page-preference-provider-impl.js","sourceRoot":"","sources":["../client/page-preference-provider-impl.ts"],"names":[],"mappings":"AAAA,OAAO,GA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,KAAK,EAAE,IAAI,EAAE,EAAE;aACrF,CAAC,CACH,CAAA;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAA;SACvD;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACnC,QAAQ,EAAE,GAAG,CAAA;;;;OAIZ;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACpB,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;aACrF,CAAC,CACH,CAAA;SACF;IACH,CAAC;CACF","sourcesContent":["import gql from 'graphql-tag'\nimport { client } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\n\nimport { PagePreferenceProvider } from './types'\n\nexport class PagePreferenceProviderImpl implements PagePreferenceProvider {\n public page?: string\n public element?: string\n public preference?: any\n\n constructor(page: string, element: string, preference?: any) {\n this.page = page\n this.element = element\n this.preference = preference\n }\n\n async load(): Promise<any> {\n const response = await client.query({\n query: gql`\n query ($page: String!, $element: String!) {\n myPagePreference(page: $page, element: $element) {\n preference\n }\n }\n `,\n variables: {\n page: this.page,\n element: this.element\n }\n })\n\n if (!response.errors) {\n this.preference = response.data.myPagePreference?.preference || {}\n return this.preference\n }\n }\n\n async save(preference: any): Promise<any> {\n const response = await client.mutate({\n mutation: gql`\n mutation ($page: String!, $element: String!, $preference: Object!) {\n updateMyPagePreference(page: $page, element: $element, preference: $preference) {\n preference\n }\n }\n `,\n variables: {\n page: this.page,\n element: this.element,\n preference\n }\n })\n\n if (!response.errors) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: { message: i18next.t('text.updated_successfully'), option: { timer: 3000 } }\n })\n )\n\n return response.data.updateMyPagePreference.preference\n }\n }\n\n async reset(): Promise<void> {\n const response = await client.mutate({\n mutation: gql`\n mutation ($page: String!, $element: String!) {\n deleteMyPagePreference(page: $page, element: $element)\n }\n `,\n variables: {\n page: this.page,\n element: this.element\n }\n })\n\n if (!response.errors) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: { message: i18next.t('text.updated_successfully'), option: { timer: 3000 } }\n })\n )\n }\n }\n}\n"]}
|