Edit Environments

This commit is contained in:
Matej Kramny 2016-06-13 20:40:16 -07:00
parent d960ec53f0
commit ecd6ef96f5
3 changed files with 24 additions and 25 deletions

View File

@ -1,15 +1,19 @@
.modal-header
h4.modal-title New Environment
h4.modal-title
span(ng-if="!env.id") New Environment
span(ng-if="env.id") Edit Environment
.modal-body
form.form-horizontal
.form-group
label.control-label.col-sm-4 Name
.col-sm-6
input.form-control(type="text" ng-model="env.name")
.form-group
.col-sm-12
textarea.form-control(ng-model="env.json" rows="20" ng-init="env.json = '{}'")
label.control-label Environment Name
input.form-control(type="text" ng-model="env.name" placeholder="Friendly name to identify your environment")
label.control-label Environment
textarea.form-control(ng-model="env.json" rows="20" placeholder="This has to be a JSON object")
p.help-block Must be valid JSON
.modal-footer
button.btn.btn-default.pull-left(ng-click="$dismiss()") Dismiss
button.btn.btn-success(ng-click="$close(env)") Create
button.btn.btn-success(ng-click="$close(env)")
span(ng-if="!env.id") Create
span(ng-if="env.id") Update

View File

@ -1,10 +0,0 @@
.modal-header
h3.modal-title Edit Environment
.modal-body
p.help-block Must be valid JSON
textarea.form-control(ng-model="env" rows="20")
.modal-footer
button.btn.btn-default.pull-left(ng-click="$dismiss()") Cancel
button.btn.btn-success(ng-click="$close(env)") Save Changes

View File

@ -15,8 +15,14 @@ define(function () {
}
$scope.add = function () {
var scope = $rootScope.$new();
scope.env = {
json: '{}'
};
$modal.open({
templateUrl: '/tpl/projects/environment/add.html'
templateUrl: '/tpl/projects/environment/add.html',
scope: scope
}).result.then(function (env) {
$http.post(Project.getURL() + '/environment', env)
.success(function () {
@ -29,14 +35,13 @@ define(function () {
$scope.editEnvironment = function (env) {
var scope = $rootScope.$new();
scope.env = env.json;
scope.env = env;
$modal.open({
templateUrl: '/tpl/projects/environment/environment.html',
templateUrl: '/tpl/projects/environment/add.html',
scope: scope
}).result.then(function (v) {
env.json = v;
$http.put(Project.getURL() + '/environment/' + env.id, env)
$http.put(Project.getURL() + '/environment/' + env.id, v)
.success(function () {
$scope.reload();
}).error(function (_, status) {