Move edit form to edit route
This commit is contained in:
parent
b00c7eef15
commit
80161e1b91
15 changed files with 124 additions and 18 deletions
1
app/components/icons/file-document-outline.js
Normal file
1
app/components/icons/file-document-outline.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { FileDocumentOutline as default } from 'ember-mdi';
|
||||
|
|
@ -1,14 +1,3 @@
|
|||
import Controller from '@ember/controller';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class AdminIndexesItemDocumentsDocumentController extends Controller {
|
||||
@action
|
||||
save(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
const data = formData.get('document');
|
||||
|
||||
this.model.index.saveDocument(data);
|
||||
}
|
||||
}
|
||||
export default class AdminIndexesItemDocumentsDocumentController extends Controller {}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import Controller from '@ember/controller';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class AdminIndexesItemDocumentsDocumentEditController extends Controller {
|
||||
@action
|
||||
save(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
const data = formData.get('document');
|
||||
|
||||
this.model.index.saveDocument(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import Controller from '@ember/controller';
|
||||
|
||||
export default class AdminIndexesItemDocumentsDocumentIndexController extends Controller {}
|
||||
|
|
@ -14,7 +14,9 @@ Router.map(function () {
|
|||
this.route('info');
|
||||
this.route('edit');
|
||||
this.route('documents', function () {
|
||||
this.route('document', { path: '/:document_id' });
|
||||
this.route('document', { path: '/:document_id' }, function () {
|
||||
this.route('edit');
|
||||
});
|
||||
this.route('new');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
12
app/routes/admin/indexes/item/documents/document/edit.js
Normal file
12
app/routes/admin/indexes/item/documents/document/edit.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import Route from '@ember/routing/route';
|
||||
// import { hash } from 'rsvp';
|
||||
|
||||
export default class AdminIndexesItemDocumentsDocumentEditRoute extends Route {
|
||||
// model({ document_id }) {
|
||||
// const index = this.modelFor('admin.indexes.item');
|
||||
// return hash({
|
||||
// index,
|
||||
// document: index.getDocument(document_id),
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import Route from '@ember/routing/route';
|
||||
|
||||
export default class AdminIndexesItemDocumentsDocumentIndexRoute extends Route {}
|
||||
|
|
@ -1,5 +1 @@
|
|||
<form {{on 'submit' this.save}}>
|
||||
<InputTextarea @name='document' @value={{stringify @model.document}} />
|
||||
|
||||
<Button type='submit' @text='Save' @style='primary' />
|
||||
</form>
|
||||
{{outlet}}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<form {{on 'submit' this.save}}>
|
||||
<InputTextarea @name='document' @value={{stringify @model.document}} />
|
||||
|
||||
<Button type='submit' @text='Save' @style='primary' />
|
||||
</form>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{{#each-in @model.document as |key value|}}
|
||||
{{#if (eq '_geo' key)}}
|
||||
{{! TODO: add map }}
|
||||
{{else}}
|
||||
<FormElement @label={{capitalize key}} @value={{stringify value}} />
|
||||
{{/if}}
|
||||
{{/each-in}}
|
||||
|
|
@ -46,6 +46,14 @@
|
|||
@route='admin.indexes.item.documents.document'
|
||||
@models={{array @model.index.uid (get data @model.index.primaryKey)}}
|
||||
class="inline-flex items-center"
|
||||
>
|
||||
<Icons::FileDocumentOutline class='mr-1' />
|
||||
View
|
||||
</LinkTo>
|
||||
<LinkTo
|
||||
@route='admin.indexes.item.documents.document.edit'
|
||||
@models={{array @model.index.uid (get data @model.index.primaryKey)}}
|
||||
class="inline-flex items-center"
|
||||
>
|
||||
<Icons::PencilOutline class='mr-1' />
|
||||
Edit
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'meiliadmin/tests/helpers';
|
||||
|
||||
module(
|
||||
'Unit | Controller | admin/indexes/item/documents/document/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/documents/document/edit'
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'meiliadmin/tests/helpers';
|
||||
|
||||
module(
|
||||
'Unit | Controller | admin/indexes/item/documents/document/index',
|
||||
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/documents/document/index'
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'meiliadmin/tests/helpers';
|
||||
|
||||
module(
|
||||
'Unit | Route | admin/indexes/item/documents/document/edit',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:admin/indexes/item/documents/document/edit'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'meiliadmin/tests/helpers';
|
||||
|
||||
module(
|
||||
'Unit | Route | admin/indexes/item/documents/document/index',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let route = this.owner.lookup(
|
||||
'route:admin/indexes/item/documents/document/index'
|
||||
);
|
||||
assert.ok(route);
|
||||
});
|
||||
}
|
||||
);
|
||||
Loading…
Reference in a new issue