Skip to main content
Sign in
Snippets Groups Projects
Commit b4ec5ab2 authored by Eugen Ciur's avatar Eugen Ciur
Browse files

adding automates routes/components

parent ef91e0f0
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ export default class AutomateModel extends Model { ...@@ -5,6 +5,7 @@ export default class AutomateModel extends Model {
@attr name; @attr name;
@attr match; @attr match;
@attr matching_algorithm; @attr matching_algorithm;
@attr dst_folder;
@attr('boolean') is_case_sensitive; @attr('boolean') is_case_sensitive;
@hasMany('tags') tags; @hasMany('tags') tags;
} }
import EmberRouter from '@ember/routing/router'; import EmberRouter from '@ember/routing/router';
import config from 'papermerge/config/environment'; import config from 'papermerge/config/environment';
export default class Router extends EmberRouter { export default class Router extends EmberRouter {
location = config.locationType; location = config.locationType;
rootURL = config.rootURL; rootURL = config.rootURL;
} }
Router.map(function () { Router.map(function () {
this.route('documents'); this.route('documents');
this.route('about');
this.route('contact', { path: '/getting-in-touch' });
this.route('document', { path: '/document/:document_id' }); this.route('document', { path: '/document/:document_id' });
this.route('node', { path: '/node/:node_id' }); this.route('node', { path: '/node/:node_id' });
this.route('tags', function () { this.route('tags', function () {
this.route('add');
this.route('edit', { path: ':tag_id/edit' });
this.route('index', { path: '/' }); this.route('index', { path: '/' });
}); });
this.route('automates', function () { this.route('automates', function () {
this.route('add'); this.route('add');
this.route('automate', { path: '/:automate_id' }); this.route('edit', { path: '/:automate_id/edit' });
this.route('index', { path: '/' }); this.route('index', { path: '/' });
}); });
... ...
......
import Route from '@ember/routing/route'; import Route from '@ember/routing/route';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
export default class TagsRoute extends Route {
export default class AutomatesRoute extends Route {
@service store; @service store;
async model(params) { async model() {
let ret = this.store.findRecord('tag', params.tag_id); return this.store.findAll('automate');
console.log(ret);
return ret;
} }
} }
import Route from '@ember/routing/route'; import Route from '@ember/routing/route';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
export default class TagsRoute extends Route { export default class TagsRoute extends Route {
@service store; @service store;
... ...
......
<h1>Automates Index</h1>
<LinkTo @route="automates.add" class="btn btn-success">New</LinkTo> <LinkTo @route="automates.add" class="btn btn-success">New</LinkTo>
<div class="tags">
<table class="table table-striped align-middle">
<thead>
<tr class="text-uppercase">
<th class="border-top-0">Name</th>
<th class="border-top-0">Match</th>
<th class="border-top-0">Destination</th>
<th class="border-top-0">Tags</th>
<th class="border-top-0">Action</th>
</tr>
</thead>
<tbody>
{{#each @model as |automate|}}
<tr>
<td>
{{automate.name}}
</td>
<td>
{{automate.match}}
</td>
<td>
{{automate.dst_folder}}
</td>
<td>
...
</td>
<td>
<button class="btn btn-link"> Edit
</button>
<button class="btn btn-link">Remove</button>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
\ No newline at end of file
{
"data": [
{
"id": 1,
"type": "automate",
"attributes": {
"name": "zdf",
"match": "ZDF",
"matching_algorithm": "any",
"is_case_sensitive": false
}
}, {
"id": 2,
"type": "automate",
"attributes": {
"name": "groceries",
"match": "LIDL|LDL",
"matching_algorithm": "any",
"is_case_sensitive": false
}
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment