rsanchez
2014-11-14 8076f3e62e24f23cc8eb866fe18cc6f00ceb02b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
   <div ng-include="'header.html'" ></div>
   <div class="container">
       <div class="col-md-12">&nbsp;</div>
       <div class="col-md-2">
           <ul class="nav nav-pills nav-stacked">
               <li ng-repeat="catalog in catalogsList" ng-class="{active: $index === catalogIndex}"><a ng-click="selectCatalog($index)" ng-bind="catalog.name"></a></li>
           </ul>
       </div>
       <div class="col-md-10">
           <div id="toolbarAndForm" ng-controller="CatalogFormCtrl">
               <nav class="navbar navbar-default navbar-static-top">
                   <!-- Brand and toggle get grouped for better mobile display -->
                   <div class="navbar-header">
                       <a class="navbar-brand" ng-bind="catalogMetadata.name"></a>
                   </div>
                   <!-- Collect the nav links, forms, and other content for toggling -->
                   <div class="collapse navbar-collapse"
                       id="bs-example-navbar-collapse-1">
                       <ul class="nav navbar-nav">
                           <li><a i18n ng-click="editNew()"><span class="glyphicon glyphicon-plus"></span>
                                   New</a></li>
                           <li><a i18n ng-click="cancel()"> <span
                                   class="glyphicon glyphicon-ban-circle"></span> Cancel
                           </a></li>
                       </ul>
                       <div class="navbar-form navbar-right">
                       <div class="input-group input-group-sm">
                             <span class="input-group-addon glyphicon glyphicon-search" style="top: 0px;"></span>
                         <input type="text" class="form-control" placeholder="Search" ng-model="$parent.searchText" >
                               <span class="btn input-group-addon glyphicon glyphicon-remove" ng-click="$parent.searchText = ''" style="top: 0px;"></span>
                       </div>
                       </div>
                   </div>
               </nav>
               
               <div class="panel panel-default animate-show ng-hide" ng-show="showForm">
                   <form role="form" class="form-horizontal " name="catalogForm" id="catalogForm" ng-submit="saveCatalog()" >
<!--                     <pre>formu: {{formu | json}}</pre>-->
                       <div class="form-group" ng-repeat="field in catalogMetadata.fields" ng-if="(!isNew || !field.autogenerate) && !field.listingOnly">
                           <label class="col-md-3 control-label" for="{{field.name}}">{{field.display}}</label>
                           <div class="col-md-5">
                               <div ng-switch on="inputType(field)">
                                   <input catalog-field ng-switch-when="normal" type="{{field.type}}" id="{{field.name}}" name="{{field.name}}" placeholder=""
                                       class="form-control" ng-model="formu[field.name]" ng-required="field.mandatory" ng-maxlength="{{field.maxlength}}" />
                                   <input catalog-field ng-switch-when="password" type="{{field.type}}" id="{{field.name}}" name="{{field.name}}" placeholder=""
                                       class="form-control" ng-model="formu[field.name]" ng-required="field.mandatory" ng-maxlength="{{field.maxlength}}" />
                                   <textarea catalog-field ng-switch-when="textarea" type="{{field.type}}" id="{{field.name}}" name="{{field.name}}" placeholder=""
                                       class="form-control" ng-model="formu[field.name]" rows="{{field.multiline}}" ng-required="field.mandatory" ng-maxlength="{{field.maxlength}}"></textarea>
                                   <p ng-switch-when="readonly" class="form-control-static">{{formu[field.name]}}</p>
                                   <p ng-switch-when="readonly_date" class="form-control-static">{{formu[field.name] | date:'medium'}}</p>
                                   <select ng-switch-when="select" class="form-control" ng-required="field.mandatory" ng-model="formu[field.name]"
                                       ng-options="o.id as o.label for o in refs[field.name]" ng-change="selectFieldChanged(field.onchange)">
                                       <option value="" ></option>
                                   </select>
                                   <select chosen multiple ng-switch-when="multiselect" class="form-control" ng-required="field.mandatory" ng-model="formu[field.name]"
                                       ng-options="o.id as o.label for o in refs[field.name]" data-placeholder="...">
                                   </select>
                                   <div ng-switch-when="metadata" >
                                       <table class="table table-hover table-condensed">
                                       <thead>
                                           <tr>
                                               <th i18n >Key</th>
                                               <th i18n >Value</th>
                                               <th i18n >Mandatory</th>
                                               <th ng-if="field.allow_creation"><span ng-click="createMetadataRow()" id="md_add" class="btn btn-success btn-xs glyphicon glyphicon-plus"></span></th>
                                           </tr>
                                       </thead>
                                       <tbody>
                                           <tr ng-repeat="row_md in formu['metadata']" >
                                             <td><input type="text" id="md_key" name="md_key" placeholder="" ng-readonly="!field.allow_creation"
                                                   class="form-control" ng-model="row_md['key']" ng-required="true" ng-maxlength="150" />
                                             </td>
                                             <td>
                                               <input type="text" id="md_value" name="md_value" placeholder=""
                                                   class="form-control" ng-model="row_md['value']" ng-required="false" ng-maxlength="150" />
                                             </td>
                                             <td>
                                               <input type="checkbox" id="md_mandatory" name="md_mandatory" ng-disabled="!field.allow_creation"
                                                   class="form-control" ng-model="row_md['mandatory']" />
                                             </td>
                                             <td ng-if="field.allow_creation">                                              
                                             <span ng-click="removeMetadataKey(row_md)" id="md_delete" class="btn btn-danger btn-xs glyphicon glyphicon-trash"></span>
                                             </td>
                                             </tr>
                                       </tbody>
                                       </table>                
                                   </div>
                               </div>
                               <div class="alert inline-alert alert-warning" ng-show="catalogForm[field.name].$invalid">
                                   <span class="glyphicon glyphicon-warning-sign"></span>
                                   <span ng-show="catalogForm[field.name].$error.maxlength">{{field.display}} length is too long (max: {{field.maxlength}}).<br/></span>
                                   <span ng-show="catalogForm[field.name].$error.required">{{field.display}} is required.</span>
                               </div>
                           </div>
                       </div>
                       <div class="form-group">
                           <div class="col-md-offset-3 col-md-10" id="saveContainer">
                               <button id="save" type="submit" class="btn btn-primary" >
                                   <span i18n class="glyphicon glyphicon-floppy-disk"></span> Save
                               </button>
                           </div>
                       </div>
                   </form>
               </div>
           </div>
           <div class="panel panel-default" ng-controller="CatalogListCtrl">
               <div class="panel-heading">
                   {{catalog.name}} <span class="badge pull-right" ng-bind="list.length || 0"></span>
               </div>
               <table class="table table-hover table-condensed">
                   <thead>
                       <tr>
                           <th ng-repeat="field in catalogMetadata.list_fields" ng-bind="display(field)"></th>
                           <th></th>
                       </tr>
                   </thead>
                   <tbody>
                       <tr ng-repeat="row in list | filter:searchText" ng-dblclick="edit(row)">
                           <td ng-repeat="field in catalogMetadata.list_fields" ng-bind="print(field, row)"></td>
                       
                           <td><span ng-click="edit(row)"
                               class="glyphicon glyphicon-pencil"></span>
                               <span ng-click="delete(row)"
                               class="glyphicon glyphicon-remove"></span>
                               </td>
                       </tr>
                   </tbody>
                   <tfoot>
                   </tfoot>
               </table>
           </div>
       </div>
   </div>