Skip to content

Commit e8e40f5

Browse files
author
Cyrille Bourgois
committed
fix(exchange): restore office attach directive
1 parent c20e1fa commit e8e40f5

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export default class OfficeAttachController {
2+
/* @ngInject */
3+
constructor(Exchange, officeAttach, ovhUserPref, User) {
4+
this.Exchange = Exchange;
5+
this.officeAttach = officeAttach;
6+
this.ovhUserPref = ovhUserPref;
7+
this.User = User;
8+
}
9+
10+
$onInit() {
11+
this.maxNumberOfAccounts = 25;
12+
this.$routerParams = this.Exchange.getParams();
13+
14+
return this.retrievingIfBannerShouldBeDisplayed();
15+
}
16+
17+
retrievingIfBannerShouldBeDisplayed() {
18+
this.canDisplay = false;
19+
20+
return this.officeAttach
21+
.retrievingIfPreferencesAllowBannerDisplaying()
22+
.then(
23+
preferencesAllowBannerDisplaying => (preferencesAllowBannerDisplaying
24+
? this.officeAttach.retrievingIfUserAlreadyHasSubscribed(this.$routerParams.productId)
25+
: true),
26+
)
27+
.then((userHasAlreadySubscribed) => {
28+
this.canDisplay = !userHasAlreadySubscribed;
29+
});
30+
}
31+
}
Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
1+
import controller from './office-attach.controller';
12
import template from './office-attach.html';
23

3-
class officeAttachController {
4-
constructor(Exchange, officeAttach, ovhUserPref, User) {
5-
this.Exchange = Exchange;
6-
this.officeAttach = officeAttach;
7-
this.ovhUserPref = ovhUserPref;
8-
this.User = User;
9-
}
10-
11-
$onInit() {
12-
this.maxNumberOfAccounts = 25;
13-
this.$routerParams = this.Exchange.getParams();
14-
15-
return this.retrievingIfBannerShouldBeDisplayed();
16-
}
17-
18-
retrievingIfBannerShouldBeDisplayed() {
19-
this.canDisplay = false;
20-
21-
return this.officeAttach
22-
.retrievingIfPreferencesAllowBannerDisplaying()
23-
.then(
24-
preferencesAllowBannerDisplaying => (preferencesAllowBannerDisplaying
25-
? this.officeAttach.retrievingIfUserAlreadyHasSubscribed(this.$routerParams.productId)
26-
: true),
27-
)
28-
.then((userHasAlreadySubscribed) => {
29-
this.canDisplay = !userHasAlreadySubscribed;
30-
});
31-
}
32-
}
33-
34-
export default {
4+
export default () => ({
355
restrict: 'E',
366
template,
37-
controller: officeAttachController,
7+
controller,
388
controllerAs: '$ctrl',
399
scope: false,
4010
replace: true,
41-
};
11+
});

0 commit comments

Comments
 (0)