</div>
<div class="col-md-8">
<div class="btn-group pull-right">
- <label class="btn btn-default" ng-click="importTemplates()">[% l('Import') %]</label>
- <label class="btn btn-default" ng-click="exportTemplates()">[% l('Export') %]</label>
+ <span class="btn btn-default btn-file">
+ [% l('Import') %]
+ <input type="file" eg-file-reader container="imported_templates.data">
+ </span>
+ <label class="btn btn-default"
+ eg-json-exporter container="templates"
+ default-file-name="'[% l('exported_copy_templates.json') %]'">
+ [% l('Export') %]
+ </label>
</div>
</div>
</div>
}
$scope.templates = {};
+ $scope.imported_templates = { data : '' };
$scope.template_name = '';
$scope.template_name_list = [];
-
+
+ $scope.$watch('imported_templates.data', function(newVal, oldVal) {
+ if (newVal && newVal != oldVal) {
+ try {
+ var newTemplates = JSON.parse(newVal);
+ if (!Object.keys(newTemplates).length) return;
+ $scope.templates = newTemplates;
+ $scope.template_name_list = Object.keys(newTemplates);
+ $scope.template_name = '';
+ } catch (E) {
+ console.log('tried to import an invalid copy template file');
+ }
+ }
+ });
+
$scope.tracker = function (x,f) { if (x) return x[f]() };
$scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
$scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };