Skip to content

Commit

Permalink
Delete DomainDelete view and allow to users to delete domains via an …
Browse files Browse the repository at this point in the history
…action of DomainController
  • Loading branch information
piroor committed Oct 4, 2012
1 parent 2d0c3fc commit c1891d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 46 deletions.
11 changes: 10 additions & 1 deletion public/js/gcs/controllers.js
Expand Up @@ -113,7 +113,16 @@ App.IndexController = Ember.ArrayController.extend({
});

App.DomainController = Ember.ObjectController.extend({
selectedAction: null
selectedAction: null,

delete: function() {
var domainName = this.get('domain').get('name');
var record = App.store.find(App.Domain, domainName);
if (record && confirm('Do you really want this domain to be deleted?')) {
App.store.deleteRecord(record);
App.store.commit();
}
}
});

App.DomainShowController = Ember.ObjectController.extend({
Expand Down
13 changes: 4 additions & 9 deletions public/js/gcs/router.js
Expand Up @@ -25,7 +25,6 @@ App.Router = Ember.Router.extend({
gotoDomainSearch: Ember.State.transitionTo('domains.search'),
gotoDomainShow: Ember.State.transitionTo('domains.show'),
gotoDomainCreate: Ember.State.transitionTo('domains.create'),
gotoDomainDelete: Ember.State.transitionTo('domains.delete'),
index: Ember.Route.extend({
route: '/',
connectOutlets: function(router) {
Expand All @@ -42,7 +41,11 @@ App.Router = Ember.Router.extend({
this.connectDomainOutlet(router, domain);
var domainController = router.get('domainController');
domainController.set('selectedAction', 'About');
domainController.set('domain', domain);
domainController.connectOutlet('domainShow', domain);
},
delete: function(router) {
router.get('domainController').delete();
}
}),
search: Ember.Route.extend(App.WithDomain, {
Expand Down Expand Up @@ -71,14 +74,6 @@ App.Router = Ember.Router.extend({
applicationController.set('selected', ['DomainCreate']);
applicationController.connectOutlet('domainCreate');
}
}),
'delete': Ember.Route.extend({
route: 'delete',
connectOutlets: function(router) {
var applicationController = router.get('applicationController');
applicationController.set('selected', ['DomainDelete']);
applicationController.connectOutlet('domainDelete');
}
})
}),
loading: Em.State.extend({})
Expand Down
19 changes: 0 additions & 19 deletions public/js/gcs/views.js
Expand Up @@ -72,22 +72,3 @@ App.DomainCreateView = Ember.View.extend({
}
})
});

App.DomainDeleteView = Ember.View.extend({
templateName: 'domain-delete',

DomainDeleteFormView: Ember.View.extend({
tagName: 'form',
classNames: 'form-horizontal',

submit: function(event) {
event.preventDefault();
var domainName = this.get('controller.domainName');
var record = App.store.find(App.Domain, domainName);
if (record) {
App.store.deleteRecord(record);
App.store.commit();
}
}
})
});
18 changes: 1 addition & 17 deletions views/index.jade
Expand Up @@ -39,9 +39,6 @@ html
{{#view view.NavItemView section="DomainCreate"}}
<a href {{action gotoDomainCreate}}><i class="icon-plus"></i> New domain</a>
{{/view}}
{{#view view.NavItemView section="DomainDelete"}}
<a href {{action gotoDomainDelete}}><i class="icon-remove"></i> Delete domain</a>
{{/view}}
.span10
{{outlet}}

Expand All @@ -63,7 +60,7 @@ html
{{#view view.NavItemView item="Search"}}
<a href {{action gotoDomainSearch this.content}}>Search</a>
{{/view}}
// <a href {{action gotoDomainDelete}} class="pull-right"><i class="icon-remove"></i> Delete</a>
<a href {{action delete}} class="pull-right"><i class="icon-remove"></i> Delete</a>

{{outlet}}

Expand Down Expand Up @@ -97,19 +94,6 @@ html
button(type="submit", class="btn btn-primary") Create
{{/view}}

script(data-template-name="domain-delete", type="text/x-handlebars")
h1 Deleting a domain

{{#view view.DomainDeleteFormView}}
.control-group
label.control-label Domain Name
.controls
{{view Ember.TextField valueBinding="domainName"}}
.control-group
.controls
button(type="submit", class="btn btn-primary") Delete
{{/view}}

script(data-template-name="domain-search", type="text/x-handlebars")
{{#view view.SearchFormView}}
{{view Ember.TextField valueBinding="query"}}
Expand Down

0 comments on commit c1891d6

Please sign in to comment.