Skip to content

Commit

Permalink
Fixes #5436: Add warning to delete buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Sep 2, 2014
1 parent 1e65e48 commit d691401
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
11 changes: 10 additions & 1 deletion builder/css/custom.css
Expand Up @@ -246,4 +246,13 @@ textarea.form-control {

.top-margin {
margin-top: -5px;
}
}

.icon-delete {
color : #990000
}

.btn-delete:hover, .btn-delete:active, .btn-delete:focus{
color: #fff;
background-color: #990000;
}
17 changes: 15 additions & 2 deletions builder/index.html
Expand Up @@ -35,6 +35,19 @@ <h3 class="modal-title">Unsaved changes</h3>
<button class="btn btn-default" ng-click="save()">Save Changes</button>
</div>
</script>
</script>
<script type="text/ng-template" id="template/confirmModal.html">
<div class="modal-header">
<h3 class="modal-title">{{actionName}} {{kind}}</h3>
</div>
<div class="modal-body">
Are you sure you want to {{actionName}} {{displayName()}}?
</div>
<div class="modal-footer">
<button class="btn btn-default pull-left" ng-click="cancel()">Cancel</button>
<button class="btn btn-default btn-delete" ng-click="confirm()">{{actionName}}</button>
</div>
</script>
<script id="template/cloneModal.html" type="text/ng-template">
<form name="cloneForm">
<div class="modal-header">
Expand Down Expand Up @@ -115,7 +128,7 @@ <h3 >Techniques</h3>
<form class="form-horizontal editForm" name="editForm" style="margin-bottom:70px;padding-left: 15px;">
<div class="title">Technique</div>
<h3 >{{originalTechnique.name}} <span ng-hide="originalTechnique.name">New Technique</span>
<button ng-disabled="isNotSaved()" class="btn btn-default pull-right top-margin" ng-click="deleteTechnique()">Delete</button>
<button ng-disabled="isNotSaved()" class="btn btn-default pull-right top-margin btn-delete" ng-click="confirmPopup('Delete','Technique', deleteTechnique, selectedTechnique, selectedTechnique.name)">Delete</button>
<button ng-disabled="isNotSaved()" class="btn btn-default pull-right top-margin right-margin" ng-click="checkSelect(selectedTechnique,clonePopup)">Clone</button>
</h3>
<accordion>
Expand Down Expand Up @@ -152,7 +165,7 @@ <h4 class="panel-title">
</a>
</span>
<i type="button" class="glyphicon pull-right icon-margin" ng-class="{'glyphicon-chevron-left': isSelectedMethod(method_call), 'glyphicon-chevron-right': !isSelectedMethod(method_call)}"></i>
<i aria-hidden="true" class="glyphicon glyphicon-trash pull-right icon-margin method-actions" ng-click="removeMethod($index); $event.stopPropagation();"></i>
<i aria-hidden="true" class="glyphicon glyphicon-trash pull-right icon-margin icon-delete method-actions" ng-click="removeMethod($index); $event.stopPropagation();"></i>
<i type="button" class="glyphicon glyphicon-circle-arrow-down pull-right icon-margin method-actions" aria-hidden="true" ng-hide="$index === selectedTechnique.method_calls.length - 1" ng-click="moveUp($index); $event.stopPropagation();"></i>
<i type="button" class="glyphicon glyphicon-circle-arrow-up pull-right icon-margin method-actions" aria-hidden="true" ng-hide="$index === 0" ng-click="moveDown($index); $event.stopPropagation();"></i>
</h4>
Expand Down
39 changes: 39 additions & 0 deletions builder/js/ncf.js
Expand Up @@ -477,11 +477,50 @@ app.controller('ncf-builder', function ($scope, $modal, $http, $log, $location,
});
};

$scope.confirmPopup = function(actionName,kind,action,elem, name) {

var modalInstance = $modal.open({
templateUrl: 'template/confirmModal.html',
controller: confirmModalCtrl,
resolve: {
actionName: function() { return actionName; }
, kind : function() { return kind; }
, name : function() { return name; }
}
});

modalInstance.result.then(function () {
action(elem)
});
};

$scope.getMethods();
$scope.getTechniques();
$scope.setPath();
});

var confirmModalCtrl = function ($scope, $modalInstance, actionName, kind, name) {

$scope.actionName = actionName;
$scope.kind = kind;
$scope.name = name;

$scope.displayName = function() {
if (name === undefined) {
return "this "+ kind;
} else {
return kind + " '" + name + "'"
}
};

$scope.confirm = function() {
$modalInstance.close();
};

$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};

var cloneModalCtrl = function ($scope, $modalInstance, technique) {

Expand Down

0 comments on commit d691401

Please sign in to comment.