Add editing index
This commit is contained in:
parent
105d8617f5
commit
cff4a195ba
10 changed files with 102 additions and 0 deletions
7
app/components/headers/h1.hbs
Normal file
7
app/components/headers/h1.hbs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<h1 class='text-3xl mb-4'>
|
||||
{{#if (has-block)}}
|
||||
{{yield}}
|
||||
{{else}}
|
||||
{{@title}}
|
||||
{{/if}}
|
||||
</h1>
|
||||
14
app/controllers/admin/indexes/item/edit.js
Normal file
14
app/controllers/admin/indexes/item/edit.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import Controller from '@ember/controller';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class AdminIndexesItemEditController extends Controller {
|
||||
@action
|
||||
save(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
const data = Object.fromEntries(formData.entries());
|
||||
|
||||
this.model.save(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,4 +88,11 @@ export default class Index {
|
|||
// ? Object.keys(this.stats.value.fieldDistribution)
|
||||
// : [];
|
||||
// }
|
||||
|
||||
save(data) {
|
||||
return query(this.indexPath, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ Router.map(function () {
|
|||
this.route('settings');
|
||||
this.route('data');
|
||||
this.route('info');
|
||||
this.route('edit');
|
||||
});
|
||||
});
|
||||
this.route('keys', function () {
|
||||
|
|
|
|||
7
app/routes/admin/indexes/item/edit.js
Normal file
7
app/routes/admin/indexes/item/edit.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class AdminIndexesItemEditRoute extends Route {
|
||||
async model() {
|
||||
return this.modelFor('admin.indexes.item');
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="flex mb-4">
|
||||
<Tab @route="admin.indexes.item.data" @text="Data" @model={{@model}} />
|
||||
<Tab @route="admin.indexes.item.info" @text="Info" @model={{@model}} />
|
||||
<Tab @route="admin.indexes.item.edit" @text="Edit" @model={{@model}} />
|
||||
{{!-- <Tab @route="admin.indexes.item.settings" @text="Settings" @model={{@model}} /> --}}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
16
app/templates/admin/indexes/item/edit.hbs
Normal file
16
app/templates/admin/indexes/item/edit.hbs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<Headers::H1>Edit {{@model.uid}}</Headers::H1>
|
||||
|
||||
<form {{on 'submit' this.save}}>
|
||||
<InputText
|
||||
@label='Primary key'
|
||||
@name='primaryKey'
|
||||
@value={{@model.primaryKey}}
|
||||
@required={{true}}
|
||||
/>
|
||||
|
||||
<Button
|
||||
type='submit'
|
||||
@text='Save'
|
||||
@style='primary'
|
||||
/>
|
||||
</form>
|
||||
26
tests/integration/components/headers/h1-test.js
Normal file
26
tests/integration/components/headers/h1-test.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'meiliadmin/tests/helpers';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | headers/h1', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
// Set any properties with this.set('myProperty', 'value');
|
||||
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||
|
||||
await render(hbs`<Headers::H1 />`);
|
||||
|
||||
assert.dom(this.element).hasText('');
|
||||
|
||||
// Template block usage:
|
||||
await render(hbs`
|
||||
<Headers::H1>
|
||||
template block text
|
||||
</Headers::H1>
|
||||
`);
|
||||
|
||||
assert.dom(this.element).hasText('template block text');
|
||||
});
|
||||
});
|
||||
12
tests/unit/controllers/admin/indexes/item/edit-test.js
Normal file
12
tests/unit/controllers/admin/indexes/item/edit-test.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'meiliadmin/tests/helpers';
|
||||
|
||||
module('Unit | Controller | admin/indexes/item/edit', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup('controller:admin/indexes/item/edit');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
11
tests/unit/routes/admin/indexes/item/edit-test.js
Normal file
11
tests/unit/routes/admin/indexes/item/edit-test.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'meiliadmin/tests/helpers';
|
||||
|
||||
module('Unit | Route | admin/indexes/item/edit', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup('route:admin/indexes/item/edit');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue