Yoji SHIDARA
null+****@clear*****
Wed Sep 26 15:32:23 JST 2012
Yoji SHIDARA 2012-09-26 15:32:23 +0900 (Wed, 26 Sep 2012) New Revision: 970bb99e41e9f4ff0461672dab4c80e64eddd400 https://github.com/groonga/gcs/commit/970bb99e41e9f4ff0461672dab4c80e64eddd400 Log: Reorganize navigation of domain selection Modified files: public/js/gcs.js views/index.jade Modified: public/js/gcs.js (+24 -19) =================================================================== --- public/js/gcs.js 2012-09-25 20:31:18 +0900 (3290ee1) +++ public/js/gcs.js 2012-09-26 15:32:23 +0900 (c119ff4) @@ -10,8 +10,6 @@ App.IndexView = Ember.View.extend({ templateName: 'index' }); -App.currentDomain = Ember.Object.create(); - App.Domain = Ember.Object.extend({ name: null, endpoint: null, @@ -98,25 +96,11 @@ App.Domains = Ember.Object.extend({ App.domains = App.Domains.create(); App.domains.fetch(); -App.domainsController = Ember.ArrayController.create({ - contentBinding: "App.domains.all", - domainsUpdated: function() { - if (!App.currentDomain) { - var first = App.domains.get('first'); - App.set('currentDomain', first); - } - }.observes("App.domains.all") -}); -App.DomainSelectorView = Ember.View.extend({ - classNames: ["navbar-form", "pull-right"] -}); - App.SearchController = Ember.ArrayController.extend({ query: null, perPage: 5, start: 0, data: null, - domainBinding: 'App.currentDomain', numStart: function() { return this.get('start') + 1; }.property('start'), @@ -236,15 +220,31 @@ App.SearchFormView = Ember.View.extend({ } }); +App.IndexController = Ember.ArrayController.extend({ + contentBinding: 'App.domains.all' +}); + +App.IndexView = Ember.View.extend({ + templateName: 'index' +}); + App.Router = Ember.Router.extend({ root: Ember.Route.extend({ + showIndex: Ember.State.transitionTo('root.index'), index: Ember.Route.extend({ route: '/', - redirectsTo: 'search' + connectOutlets: function(router) { + router.get('applicationController').connectOutlet('index'); + }, + search: function(router, event) { + router.transitionTo('search', {domain: event.context}); + }, }), search: Ember.Route.extend({ - route: 'search', - connectOutlets: function(router) { + route: 'search/:domainName', + connectOutlets: function(router, context) { + var controller = router.get('searchController'); + controller.set('domain', context.domain); router.get('applicationController').connectOutlet('search'); }, nextPage: function(router) { @@ -252,6 +252,11 @@ App.Router = Ember.Router.extend({ }, previousPage: function(router) { router.get('searchController').previousPage(); + }, + serialize: function(router, context) { + return { + domainName: context.domain.name + }; } }) }) Modified: views/index.jade (+25 -6) =================================================================== --- views/index.jade 2012-09-25 20:31:18 +0900 (c06eb7f) +++ views/index.jade 2012-09-26 15:32:23 +0900 (2cdabd5) @@ -14,20 +14,39 @@ html .navbar.navbar-fixed-top .navbar-inner .container - a.brand(href="/") Groonga CloudSearch - {{#view App.DomainSelectorView}} - {{view Ember.Select contentBinding="App.domainsController.content" optionLabelPath="content.name" selectionBinding="App.currentDomain"}} - {{/view}} - p.navbar-text.pull-right Domain: + <a class="brand" {{action showIndex}}>Groonga CloudSearch</a> .container .row .span12 {{outlet}} script(data-template-name="index", type="text/x-handlebars") - h1 TODO + h1 Global Configuration + table.table.table-bordered + tbody + tr + th Configuration Endpoint + td {{App.domains.configurationEndpoint}} + h1 Available Domains + {{#each controller}} + h2 <a {{action search this}}>{{name}}</a> + table.table.table-bordered + tbody + tr + th Search Endpoint + td {{searchEndpoint}} + tr + th Fields + td + ul + {{#each fieldNames}} + li {{this}} + {{/each}} + {{/each}} + script(data-template-name="search", type="text/x-handlebars") + h2 Search domain '{{domain.name}}' {{#view App.SearchFormView}} {{view Ember.TextField valueBinding="query"}} input(type="hidden", name="start", value="") -------------- next part -------------- HTML����������������������������... Descargar