</div>
</div>
<div class="row">
- <div class="col-md-2">
- <label for="pattern_name">[% l('Share this pattern as a template?') %]</label>
- <input id="pattern_name" type="text" ng-model="pattern_name">
+ <div class="col-md-8">
+ <label for="pattern_name">[% l('Enter a name to share this pattern as a template') %]</label>
+ <input id="pattern_name" type="text" ng-model="share.pattern_name">
+ <label for="share_depth">[% l('Share with') %]</label>
+ <eg-share-depth-selector ng-model="share.depth"></eg-share-depth-selector>
</div>
</div>
<div class="row">
} else {
$scope.pattern = new PredictionPattern();
}
+
+ // possible sharing
+ $scope.share = {
+ pattern_name : null,
+ depth : 0
+ };
+
$scope.handle_save = function() {
$scope.patternCode = JSON.stringify($scope.pattern.compile());
- if (angular.isFunction($scope.onSave)) {
- $scope.onSave($scope.patternCode);
+ if ($scope.share.pattern_name !== null) {
+ var spt = new egCore.idl.spt();
+ spt.name($scope.share.pattern_name);
+ spt.pattern_code($scope.patternCode);
+ spt.share_depth($scope.share.depth);
+ spt.owning_lib(egCore.auth.user().ws_ou());
+ egCore.pcrud.create(spt).then(function() {
+ if (angular.isFunction($scope.onSave)) {
+ $scope.onSave($scope.patternCode);
+ }
+ });
+ } else {
+ if (angular.isFunction($scope.onSave)) {
+ $scope.onSave($scope.patternCode);
+ }
}
}