Yoji SHIDARA
null+****@clear*****
Wed Nov 7 11:51:49 JST 2012
Yoji SHIDARA 2012-11-07 11:51:49 +0900 (Wed, 07 Nov 2012) New Revision: beed6b50b84f8f694ed6870b78be86c4284a6d24 https://github.com/groonga/gcs-console/commit/beed6b50b84f8f694ed6870b78be86c4284a6d24 Log: Implement DeleteIndexField operation Modified files: app.js routes/index.js test/index-fields.test.js views/domain-index-fields.jade Modified: app.js (+1 -0) =================================================================== --- app.js 2012-11-07 11:49:15 +0900 (e2adfe2) +++ app.js 2012-11-07 11:51:49 +0900 (4cdc304) @@ -46,6 +46,7 @@ function setupApplication(app) { app.get('/domain_create', auth, routes.domainCreate); app.post('/domain_create', auth, routes.domainCreatePost); app.post('/domain/:name/index_fields', auth, routes.domainCreateIndexField); + app.delete('/domain/:name/index_fields/:indexFieldName', auth, routes.domainDeleteIndexField); app.delete('/domain/:name', auth, routes.domainDelete); } Modified: routes/index.js (+22 -0) =================================================================== --- routes/index.js 2012-11-07 11:49:15 +0900 (8e1e620) +++ routes/index.js 2012-11-07 11:51:49 +0900 (2e3abe9) @@ -226,3 +226,25 @@ exports.domainCreateIndexField = function(req, res) { }); }); }; + +exports.domainDeleteIndexField = function(req, res) { + withDomain(req, res, function(req, res) { + req.cloudsearch.DeleteIndexField({ + DomainName: req.domain.DomainName, + IndexFieldName: req.params.indexFieldName + }, function(error, data) { + if (error) { + res.status(500); + res.render('domain-index-fields', { + error: errorToRender(error), + action: 'domain_index_fields', + domain: req.domain, + indexFields: req.indexFields + }); + return; + } + req.flash('info', 'IndexField successfully created'); + res.redirect('/domain/' + req.domain.DomainName + '/index_fields'); + }); + }); +}; Modified: test/index-fields.test.js (+8 -1) =================================================================== --- test/index-fields.test.js 2012-11-07 11:49:15 +0900 (6802f37) +++ test/index-fields.test.js 2012-11-07 11:51:49 +0900 (8f8524b) @@ -11,7 +11,7 @@ suite('dashboard', function() { target.teardown() }); - test('Create domain and add an index field', function(done) { + test('Create domain, add an index field and delete the index field', function(done) { var browser = new Browser(); browser .visit(target.rootURL) @@ -37,6 +37,13 @@ suite('dashboard', function() { assert.equal(browser.location.pathname, "/domain/test/index_fields"); assert.equal(browser.text(".alert"), "IndexField successfully created"); }) + .then(function() { + return browser.pressButton('Delete') + }) + .then(function() { + assert.equal(browser.location.pathname, "/domain/test/index_fields"); + assert.equal(browser.text('.alert-warn'), "No IndexField is defined"); + }) .then(done, done); }); }); Modified: views/domain-index-fields.jade (+8 -0) =================================================================== --- views/domain-index-fields.jade 2012-11-07 11:49:15 +0900 (c1ae335) +++ views/domain-index-fields.jade 2012-11-07 11:51:49 +0900 (853a0f5) @@ -9,6 +9,7 @@ block domain-content th Type th Facet th Result + th Operation for indexField in indexFields tr th= indexField.Options.IndexFieldName @@ -23,6 +24,13 @@ block domain-content default td td + td + form(action="/domain/"+domain.DomainName+"/index_fields/"+indexField.Options.IndexFieldName, method="POST").modal-form + input(type="hidden", name="_method", value="DELETE") + button(type="submit").btn.btn-danger + i.icon-trash.icon-white + | Delete + // TODO confirmation else .alert.alert-warn No IndexField is defined -------------- next part -------------- HTML����������������������������...Download