Yoji SHIDARA
null+****@clear*****
Fri Sep 28 17:01:30 JST 2012
Yoji SHIDARA 2012-09-28 17:01:30 +0900 (Fri, 28 Sep 2012) New Revision: 7a68ffe3b26ad005e78902db8ae47ced48fb9b63 https://github.com/groonga/gcs/commit/7a68ffe3b26ad005e78902db8ae47ced48fb9b63 Log: Implement domain details view Modified files: public/js/gcs.js views/index.jade Modified: public/js/gcs.js (+42 -1) =================================================================== --- public/js/gcs.js 2012-09-28 17:01:06 +0900 (07c2baa) +++ public/js/gcs.js 2012-09-28 17:01:30 +0900 (ec24f45) @@ -48,8 +48,12 @@ App.Domain.reopenClass({ get configurationEndpoint() { return 'http://' + this.host + '/'; }, + all: null, findAll: function() { - var domains = Ember.ArrayProxy.create({content: Ember.A()}); + var domains = Ember.ArrayProxy.create({ + content: Ember.A(), + didLoad: false + }); var self = this; $.ajax({ type: 'GET', @@ -73,9 +77,19 @@ App.Domain.reopenClass({ domain.fetchFields(); domains.pushObject(domain); }); + domains.set('didLoad', true); } }); return domains; + }, + find: function(name) { + var deferred = $.Deferred(); + var domains = this.findAll(); + domains.addObserver('didLoad', function() { + var domain = domains.findProperty('name', name); + deferred.resolve(domain); + }); + return deferred.promise(); } }); @@ -213,18 +227,45 @@ App.IndexView = Ember.View.extend({ templateName: 'index' }); +App.DomainController = Ember.ObjectController.extend({ +}); + +App.DomainView = Ember.View.extend({ + templateName: 'domain' +}); + App.Router = Ember.Router.extend({ root: Ember.Route.extend({ showIndex: Ember.State.transitionTo('root.index'), showSearch: function(router, event) { router.transitionTo('search', {domain: event.context}); }, + showDomain: function(router, event) { + router.transitionTo('domains.show', event.context); + }, index: Ember.Route.extend({ route: '/', connectOutlets: function(router, context) { router.get('applicationController').connectOutlet('index'); } }), + domains: Ember.Route.extend({ + route: 'domains', + show: Ember.Route.extend({ + route: ':domainName', + connectOutlets: function(router, context) { + router.get('applicationController').connectOutlet('domain', context); + }, + serialize: function(router, context) { + return { + domainName: context.name + }; + }, + deserialize: function(router, params) { + return App.Domain.find(params.domainName); + } + }) + }), search: Ember.Route.extend({ route: 'search/:domainName', connectOutlets: function(router, context) { Modified: views/index.jade (+19 -1) =================================================================== --- views/index.jade 2012-09-28 17:01:06 +0900 (ef75456) +++ views/index.jade 2012-09-28 17:01:30 +0900 (6d208e5) @@ -24,7 +24,9 @@ html ul.nav.nav-list li.nav-header Domains {{#each App.domains}} - li <a href {{action showSearch this}}>{{name}}</a> + li <a href {{action showDomain this}}>{{name}}</a> + ul.nav.nav-list + li <a href {{action showSearch this}}>search</a> {{/each}} .span10 {{outlet}} @@ -37,6 +39,22 @@ html th Configuration Endpoint td {{App.Domain.configurationEndpoint}} + script(data-template-name="domain", type="text/x-handlebars") + h1 Domain '{{name}}' + + table.table.table-bordered + tbody + tr + th Search Endpoint + td {{searchEndpoint}} + tr + th Fields + td + ul + {{#each fieldNames}} + li {{this}} + {{/each}} + script(data-template-name="search", type="text/x-handlebars") h1 Search domain '{{domain.name}}' {{#view App.SearchFormView}} -------------- next part -------------- HTML����������������������������...Download