Skip to content

Commit

Permalink
Add new duplicate modal to logic model
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonbsn committed Apr 24, 2024
1 parent 51d298c commit d51fa53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/angular/logic/logic.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2 class="h4"><icon-logic title="{{'Logic model' | translate}}"></icon-logic> {
<li><a data-ng-click="$ctrl.zoomIn()" title="{{ 'Zoom in (Z +)' | translate }}"><i class="fa fa-search-plus"></i></a></li>
<li><a data-ng-click="$ctrl.zoomNone()" title="{{ 'Zoom 100% (Z 0)' | translate }}"><i class="fa fa-search"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.zoomOut()" title="{{ 'Zoom out (Z -)' | translate }}"><i class="fa fa-search-minus"></i></a></li>
<li><a data-ng-click="$ctrl.duplicateModel()" title="{{ 'Duplicate model' | translate }}"><i class="fa fa-files-o"></i></a></li>
<li><a data-ng-click="$ctrl.duplicateModel($ctrl.model)" title="{{ 'Duplicate model' | translate }}"><i class="fa fa-files-o"></i></a></li>
<li><a data-ng-click="$ctrl.generateSQL()" title="{{ 'Generate SQL' | translate }}"><i class="fa fa-database"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.shareModel($ctrl.model)" title="{{ 'Share' | translate }}"><i class="fa fa-share-alt"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.print()" title="{{ 'Print (CTRL P)' | translate }}"><i class="fa fa-print"></i></a></li>
Expand Down
38 changes: 19 additions & 19 deletions app/angular/logic/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,33 +204,33 @@ const controller = function (
});
}

ctrl.duplicateModel = () => {
ctrl.duplicateModel = (model) => {
const modalInstance = $uibModal.open({
animation: true,
template: '<duplicate-model-modal suggested-name="$ctrl.suggestedName" close="$close(result)" dismiss="$dismiss(reason)"></duplicate-model-modal>',
controller: function () {
template: `<duplicate-model-modal
suggested-name="$ctrl.suggestedName"
close="$close(result)"
dismiss="$dismiss(reason)"
user-id=$ctrl.userId
model-id=$ctrl.modelId>
</duplicate-model-modal>`,
controller: function() {
const $ctrl = this;
$ctrl.suggestedName = $filter('translate')("MODEL_NAME (copy)", { name: ctrl.model.name });
$ctrl.suggestedName = $filter('translate')("MODEL_NAME (copy)", { name: model.name });
$ctrl.modelId = model.id;
$ctrl.userId = model.user;
},
controllerAs: '$ctrl',
});
modalInstance.result.then((newName) => {
ctrl.setLoading(true);
const duplicatedModel = {
id: "",
name: newName,
type: ctrl.model.type,
model: JSON.stringify(LogicService.graph),
user: ctrl.model.user,
};
ModelAPI.saveModel(duplicatedModel).then((newModel) => {
window.open($state.href('logic', { references: { 'modelid': newModel._id } }));
ctrl.showFeedback("Successfully duplicated!", true, 'success');
ctrl.setLoading(false);
});
}).result;
modalInstance.then((newModel) => {
window.open($state.href('logic', { references: { 'modelid': newModel._id } }));
ctrl.showFeedback("Successfully duplicated!", true, 'success');
}).catch(error => {
console.error(error);
});
};


ctrl.shareModel = (model) => {
const modalInstance = $uibModal.open({
animation: true,
Expand Down

0 comments on commit d51fa53

Please sign in to comment.