@sprucelabs/spruce-role-utils 0.4.2 → 0.4.5
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.
|
@@ -4,6 +4,7 @@ export default class RoleSelectCardViewController extends AbstractViewController
|
|
|
4
4
|
private isLoaded;
|
|
5
5
|
protected activeCardVc: ActiveRecordCardViewController;
|
|
6
6
|
private changeHandler?;
|
|
7
|
+
private shouldIgnoreControlChanges;
|
|
7
8
|
constructor(options: ViewControllerOptions & RoleSelectCardOptions);
|
|
8
9
|
private RoleListVc;
|
|
9
10
|
private renderRow;
|
|
@@ -13,6 +13,7 @@ export default class RoleSelectCardViewController extends AbstractViewController
|
|
|
13
13
|
constructor(options) {
|
|
14
14
|
super(options);
|
|
15
15
|
this.isLoaded = false;
|
|
16
|
+
this.shouldIgnoreControlChanges = false;
|
|
16
17
|
const { onChange } = options;
|
|
17
18
|
this.changeHandler = onChange;
|
|
18
19
|
this.activeCardVc = this.RoleListVc(options);
|
|
@@ -32,7 +33,9 @@ export default class RoleSelectCardViewController extends AbstractViewController
|
|
|
32
33
|
checkboxInput: {
|
|
33
34
|
name: 'isEnabled',
|
|
34
35
|
onChange: (enabled) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
|
|
36
|
+
if (!this.shouldIgnoreControlChanges) {
|
|
37
|
+
yield this.handleClickEnableCheckbox(role.id, enabled);
|
|
38
|
+
}
|
|
36
39
|
}),
|
|
37
40
|
},
|
|
38
41
|
},
|
|
@@ -46,7 +49,11 @@ export default class RoleSelectCardViewController extends AbstractViewController
|
|
|
46
49
|
name: 'requirement',
|
|
47
50
|
isRequired: true,
|
|
48
51
|
value: 'optional',
|
|
49
|
-
onChange: this
|
|
52
|
+
onChange: () => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (!this.shouldIgnoreControlChanges) {
|
|
54
|
+
yield this.handleDidChange();
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
50
57
|
choices: [
|
|
51
58
|
{
|
|
52
59
|
value: 'optional',
|
|
@@ -108,20 +115,16 @@ export default class RoleSelectCardViewController extends AbstractViewController
|
|
|
108
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
116
|
const rowVc = this.rowVc(roleId);
|
|
110
117
|
rowVc.setIsEnabled(true);
|
|
118
|
+
this.shouldIgnoreControlChanges = true;
|
|
119
|
+
yield rowVc.setValue('isEnabled', true);
|
|
111
120
|
yield rowVc.setValue('requirement', requirement);
|
|
121
|
+
this.shouldIgnoreControlChanges = false;
|
|
112
122
|
});
|
|
113
123
|
}
|
|
114
124
|
selectRole(id, requirement = 'optional') {
|
|
115
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const current = rowVc.getValue('requirement');
|
|
119
|
-
if (current !== requirement) {
|
|
120
|
-
yield rowVc.setValue('requirement', requirement);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
yield this.handleDidChange();
|
|
124
|
-
}
|
|
126
|
+
yield this.enableRow(id, requirement);
|
|
127
|
+
yield this.handleDidChange();
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
getRow(roleId) {
|
|
@@ -4,6 +4,7 @@ export default class RoleSelectCardViewController extends AbstractViewController
|
|
|
4
4
|
private isLoaded;
|
|
5
5
|
protected activeCardVc: ActiveRecordCardViewController;
|
|
6
6
|
private changeHandler?;
|
|
7
|
+
private shouldIgnoreControlChanges;
|
|
7
8
|
constructor(options: ViewControllerOptions & RoleSelectCardOptions);
|
|
8
9
|
private RoleListVc;
|
|
9
10
|
private renderRow;
|
|
@@ -6,6 +6,7 @@ class RoleSelectCardViewController extends heartwood_view_controllers_1.Abstract
|
|
|
6
6
|
constructor(options) {
|
|
7
7
|
super(options);
|
|
8
8
|
this.isLoaded = false;
|
|
9
|
+
this.shouldIgnoreControlChanges = false;
|
|
9
10
|
const { onChange } = options;
|
|
10
11
|
this.changeHandler = onChange;
|
|
11
12
|
this.activeCardVc = this.RoleListVc(options);
|
|
@@ -25,7 +26,9 @@ class RoleSelectCardViewController extends heartwood_view_controllers_1.Abstract
|
|
|
25
26
|
checkboxInput: {
|
|
26
27
|
name: 'isEnabled',
|
|
27
28
|
onChange: async (enabled) => {
|
|
28
|
-
|
|
29
|
+
if (!this.shouldIgnoreControlChanges) {
|
|
30
|
+
await this.handleClickEnableCheckbox(role.id, enabled);
|
|
31
|
+
}
|
|
29
32
|
},
|
|
30
33
|
},
|
|
31
34
|
},
|
|
@@ -39,7 +42,11 @@ class RoleSelectCardViewController extends heartwood_view_controllers_1.Abstract
|
|
|
39
42
|
name: 'requirement',
|
|
40
43
|
isRequired: true,
|
|
41
44
|
value: 'optional',
|
|
42
|
-
onChange:
|
|
45
|
+
onChange: async () => {
|
|
46
|
+
if (!this.shouldIgnoreControlChanges) {
|
|
47
|
+
await this.handleDidChange();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
43
50
|
choices: [
|
|
44
51
|
{
|
|
45
52
|
value: 'optional',
|
|
@@ -94,18 +101,14 @@ class RoleSelectCardViewController extends heartwood_view_controllers_1.Abstract
|
|
|
94
101
|
async enableRow(roleId, requirement) {
|
|
95
102
|
const rowVc = this.rowVc(roleId);
|
|
96
103
|
rowVc.setIsEnabled(true);
|
|
104
|
+
this.shouldIgnoreControlChanges = true;
|
|
105
|
+
await rowVc.setValue('isEnabled', true);
|
|
97
106
|
await rowVc.setValue('requirement', requirement);
|
|
107
|
+
this.shouldIgnoreControlChanges = false;
|
|
98
108
|
}
|
|
99
109
|
async selectRole(id, requirement = 'optional') {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const current = rowVc.getValue('requirement');
|
|
103
|
-
if (current !== requirement) {
|
|
104
|
-
await rowVc.setValue('requirement', requirement);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
await this.handleDidChange();
|
|
108
|
-
}
|
|
110
|
+
await this.enableRow(id, requirement);
|
|
111
|
+
await this.handleDidChange();
|
|
109
112
|
}
|
|
110
113
|
getRow(roleId) {
|
|
111
114
|
return this.activeCardVc.getRowVc(roleId);
|