OSDN Git Service

Modified: Upload, Command execution
[eos/zephyr.git] / front-end / app / scripts / directives / Option.ts
1 namespace app.directives {
2   export class Option implements ng.IDirective {
3
4     public restrict: string;
5     public replace: boolean;
6     public templateUrl: string;
7     public bindToController: Object;
8     public controller: string;
9     public controllerAs: string;
10     public scope: boolean;
11
12     /**
13     * constructor
14     *
15     * @param
16     */
17     constructor() {
18       this.restrict = 'E';
19       this.replace = true;
20       this.controller = 'optionController';
21       this.bindToController = {
22         info: '=',
23         files: '='
24       };
25       this.scope = true;
26       this.templateUrl = 'templates/option.html';
27       this.controllerAs = 'ctrl';
28     }
29
30     /**
31     * instance生成
32     * @returns {function(): HeaderMenu}
33     * @constructor
34     */
35     public static Factory(): ng.IDirectiveFactory {
36       var directive = () => {
37         return new Option();
38       };
39       directive.$inject = [];
40       return directive;
41     }
42   }
43
44   export class OptionController {
45
46     public static $inject = [];
47
48     private info: declares.IOption;
49
50     constructor() {
51       var controller = this;
52
53       // データバインディングしているarg.inputに
54       // OptionControlFileに記された初期値(arg.initialValue)を代入
55       angular.forEach(controller.info.arg, (arg) => {
56         if(arg.initialValue) {
57           if(arg.formType === 'number') {
58             arg.input = parseInt(arg.initialValue);
59           } else {
60             arg.input = arg.initialValue;
61           }
62         }
63       });
64     }
65   }
66 }