@@ -50,6 +50,8 @@ export class EditPermissionsDialog
50
50
51
51
private originalValues : AccessControlEntry [ ] ;
52
52
53
+ private totalChildren : number ;
54
+
53
55
constructor ( ) {
54
56
super ( {
55
57
steps : [ new MainAccessStep ( ) , new ApplyAccessToStep ( ) , new StrategyStep ( ) , new SummaryStep ( ) ] ,
@@ -102,7 +104,7 @@ export class EditPermissionsDialog
102
104
} ) ;
103
105
104
106
this . secondaryAction . onExecuted ( ( ) => {
105
- this . submit ( ) ;
107
+ this . showStep ( this . summaryStep ) ;
106
108
} ) ;
107
109
108
110
this . mainStep . onDataChanged ( ( ) => {
@@ -114,6 +116,7 @@ export class EditPermissionsDialog
114
116
115
117
this . applyToStep . onDataChanged ( ( ) => {
116
118
this . strategyStep . setApplyTo ( this . applyToStep . getData ( ) . applyTo ) ;
119
+ this . secondaryAction . setLabel ( i18n ( 'dialog.permissions.step.action.submitNow' , this . getTotalItemsToApplyTo ( ) ) ) ;
117
120
} ) ;
118
121
}
119
122
@@ -134,7 +137,7 @@ export class EditPermissionsDialog
134
137
135
138
req . sendAndParse ( ) . then ( ( taskId ) => {
136
139
this . pollTask ( taskId ) ;
137
- } ) . done ( ) ;
140
+ } ) . catch ( DefaultErrorHandler . handle ) . done ( ) ;
138
141
}
139
142
140
143
private collectData ( ) : PermissionsData {
@@ -149,9 +152,10 @@ export class EditPermissionsDialog
149
152
this . contentId = event . getContentId ( ) ;
150
153
151
154
new GetDescendantsOfContentsRequest ( event . getContentPath ( ) ) . sendAndParse ( ) . then ( ( ids ) => {
152
- this . applyToStep . setup ( ids . length ) ;
153
- this . strategyStep . setApplyTo ( ids . length === 0 ? 'single' : 'tree' ) ;
154
- this . secondaryAction . setLabel ( i18n ( 'dialog.permissions.step.action.submitNow' , ids . length + 1 ) ) ;
155
+ this . totalChildren = ids . length ;
156
+ this . applyToStep . setup ( this . totalChildren ) ;
157
+ this . strategyStep . setApplyTo ( this . totalChildren === 0 ? 'single' : 'tree' ) ;
158
+ this . secondaryAction . setLabel ( i18n ( 'dialog.permissions.step.action.submitNow' , this . totalChildren + 1 ) ) ;
155
159
} ) . catch ( DefaultErrorHandler . handle ) ;
156
160
157
161
AccessControlHelper . getParentPermissions ( event . getContentPath ( ) . getParentPath ( ) ) . then ( ( parentPermissions : AccessControlList ) => {
@@ -172,22 +176,23 @@ export class EditPermissionsDialog
172
176
protected showStep ( step : DialogStep ) : void {
173
177
super . showStep ( step ) ;
174
178
175
- const isLastStep = this . isLastStep ( ) ;
176
-
177
- if ( isLastStep ) {
178
- this . summaryStep . setCurrentData ( this . collectData ( ) ) ;
179
- }
180
-
181
- this . getButtonRow ( ) . toggleClass ( 'last-step' , isLastStep ) ;
182
-
183
- if ( step === this . strategyStep ) {
184
- this . strategyStep . setCurrentlySelectedItems ( this . collectData ( ) . permissions ) ;
185
- }
186
-
187
179
if ( this . isFirstStep ( ) ) {
188
180
this . backActionMirror . setLabel ( i18n ( 'dialog.permissions.step.action.reset' ) ) ;
189
181
this . backActionMirror . setEnabled ( this . mainStep . isAnyPermissionChanged ( ) ) ;
182
+ this . getButtonRow ( ) . removeClass ( 'last-step' ) ;
190
183
} else {
184
+ const isLastStep = this . isLastStep ( ) ;
185
+
186
+ if ( isLastStep ) {
187
+ this . summaryStep . setCurrentData ( this . collectData ( ) ) ;
188
+ }
189
+
190
+ this . getButtonRow ( ) . toggleClass ( 'last-step' , isLastStep ) ;
191
+
192
+ if ( step === this . strategyStep ) {
193
+ this . strategyStep . setCurrentlySelectedItems ( this . collectData ( ) . permissions ) ;
194
+ }
195
+
191
196
this . backActionMirror . setEnabled ( true ) . setLabel ( i18n ( 'dialog.multistep.previous' ) ) ;
192
197
}
193
198
}
@@ -200,8 +205,6 @@ export class EditPermissionsDialog
200
205
super . handleHidden ( ) ;
201
206
202
207
this . reset ( ) ;
203
-
204
- this . secondaryAction . setLabel ( i18n ( 'dialog.permissions.step.action.submitNow' , '?' ) ) ;
205
208
}
206
209
207
210
protected reset ( ) : void {
@@ -228,6 +231,24 @@ export class EditPermissionsDialog
228
231
return this . getButtonRow ( ) . getActions ( ) [ 1 ] ;
229
232
}
230
233
234
+ private getTotalItemsToApplyTo ( ) : number {
235
+ const applyTo = this . applyToStep . getData ( ) . applyTo ;
236
+
237
+ if ( applyTo === 'single' ) {
238
+ return 1 ;
239
+ }
240
+
241
+ if ( applyTo === 'subtree' ) {
242
+ return this . totalChildren ;
243
+ }
244
+
245
+ return this . totalChildren + 1 ;
246
+ }
247
+
248
+ protected getSubmitActionLabel ( ) : string {
249
+ return i18n ( 'dialog.permissions.step.action.submitNow' , this . getTotalItemsToApplyTo ( ) ) ;
250
+ }
251
+
231
252
isDirty ( ) : boolean {
232
253
return this . mainStep . isAnyPermissionChanged ( ) ;
233
254
}
0 commit comments