Refactor modalWrapper directive

pull/4840/head
Alex Dik 8 years ago
parent ac181c0754
commit 98ebbe3f92
  1. 2
      frontend/app/angular-modules.ts
  2. 25
      frontend/app/components/modals/modal-wrapper/modal-wrapper.directive.ts

@ -29,7 +29,7 @@
declare const I18n: op.I18n;
// global
angular.module('openproject.uiComponents',
export const opUiComponentsModule = angular.module('openproject.uiComponents',
['ui.select', 'ui.router', 'ngSanitize', 'openproject.workPackages.services'])
.run(['$rootScope', function ($rootScope) {
$rootScope.I18n = I18n;

@ -26,14 +26,16 @@
// See doc/COPYRIGHT.rdoc for more details.
// ++
import IAugmentedJQuery = angular.IAugmentedJQuery;
import {IDialogService} from 'ng-dialog';
import {opUiComponentsModule} from '../../../angular-modules';
import IAugmentedJQuery = angular.IAugmentedJQuery;
export class ModalWrapperController {
private modalBody:string;
public modal:any;
public modalParams:any;
private modalBody: string;
public modal: any;
public modalParams: any;
private modalOptions:any = {
private modalOptions: any = {
plain: true,
closeByEscape: true,
closeByDocument: false,
@ -42,8 +44,8 @@ export class ModalWrapperController {
constructor(protected $element,
protected $scope,
protected $attrs:ng.IAttributes,
protected ngDialog:IDialogService) {
protected $attrs: ng.IAttributes,
protected ngDialog: IDialogService) {
// Set template from wrapped element
const wrappedElement = $element.find('.modal-wrapper--content');
@ -54,7 +56,8 @@ export class ModalWrapperController {
if (!!$attrs['initialize']) {
this.initialize();
} else {
}
else {
$element.find('.modal-wrapper--activation-link').click(() => this.initialize());
}
}
@ -70,12 +73,10 @@ function modalWrapper() {
scope: {
modalParams: '='
},
bindToController: true,
controller: ModalWrapperController,
controllerAs: '$ctrl',
bindToController: true,
};
}
angular
.module('openproject.uiComponents')
.directive('modalWrapper', modalWrapper);
opUiComponentsModule.directive('modalWrapper', modalWrapper);

Loading…
Cancel
Save