diff --git a/app/components/breadcrumb/index.hbs b/app/components/breadcrumb/index.hbs index a12ba820ede3d70d8c6ff6b6ea9988e129419110..cc88a5f6fca79c2ace74de7ba7e268cbca785142 100644 --- a/app/components/breadcrumb/index.hbs +++ b/app/components/breadcrumb/index.hbs @@ -5,6 +5,7 @@ <DualLinkTo @node={{node}} @extranode={{@extranode}} + @extradoc={{@extradoc}} @hint={{@hint}} /> </li> {{/each}} diff --git a/app/components/commander/action_modes.hbs b/app/components/commander/action_modes.hbs index b66064c4ae7b85a4c01a546c8c187e4a514e12c0..e1927090aae6283328a5094b45521bfad26d835e 100644 --- a/app/components/commander/action_modes.hbs +++ b/app/components/commander/action_modes.hbs @@ -3,7 +3,7 @@ @onViewModeChange={{@onViewModeChange}} /> <div class="panel-mode"> <button type="button" class="btn btn-light mx-1" - {{on "click" @onPanelToggle}}> + {{on "click" (fn @onPanelToggle "nodes") }}> {{#if @dualPanelMode}} <i class="bi-x"></i> {{else}} diff --git a/app/components/commander/index.hbs b/app/components/commander/index.hbs index f7c82812949aa121c7029180204467361d58b22e..8dddf46d1b795ec127abf4d35938fc0fc3268ee9 100644 --- a/app/components/commander/index.hbs +++ b/app/components/commander/index.hbs @@ -35,6 +35,7 @@ <Breadcrumb @node={{@node}} @extranode={{@extranode}} + @extradoc={{@extradoc}} @hint={{@hint}} /> <div class="view-mode-{{this.view_mode}}"> @@ -48,14 +49,18 @@ <DualLinkTo @node={{node}} @extranode={{@extranode}} + @extradoc={{@extradoc}} @hint={{@hint}} /> </NodeType> {{/let}} {{/each}} </div> - <Pagination - @object={{@pagination}} - @node={{@node}} - @hint={{@hint}} /> + {{#if @pagination }} + <Pagination + @object={{@pagination}} + @node={{@node}} + @hint={{@hint}} /> + {{/if}} + </div> diff --git a/app/components/dual_link_to/index.js b/app/components/dual_link_to/index.js index 62579022ba7ad125a245d41fff6f0424668378ce..356052c8cfdcef85229e03c16f3995f9cb1a64cc 100644 --- a/app/components/dual_link_to/index.js +++ b/app/components/dual_link_to/index.js @@ -43,11 +43,13 @@ export default class DualLinkToComponent extends Component { get route() { let node, extranode, + extradoc, hint; hint = this.args.hint; node = this.args.node; extranode = this.args.extranode; + extradoc = this.args.extradoc; if (hint == 'left') { if (node && node.get('nodeType') === 'document') { @@ -64,23 +66,33 @@ export default class DualLinkToComponent extends Component { return 'authenticated.document'; } + if (extradoc) { + return 'authenticated.document'; + } + return 'authenticated.nodes'; } get model() { let hint, node, - extranode; + extranode, + extradoc; hint = this.args.hint; node = this.args.node; extranode = this.args.extranode; - + extradoc = this.args.extradoc; if (hint === 'left') { return node; } + // hint right + if (extradoc) { + return extradoc; + } + return extranode; } diff --git a/app/components/pagination/index.js b/app/components/pagination/index.js index 52bc652b5f29f3187d179dedcef41ff6ba92b649..678dd957900b837dc5e114197f4a8b9568791439 100644 --- a/app/components/pagination/index.js +++ b/app/components/pagination/index.js @@ -2,6 +2,12 @@ import Component from '@glimmer/component'; export default class PaginationComponent extends Component { + /* + Arguments: + @object + @node + @hint = { "left" | "right" } + */ get pages() { let result = [], diff --git a/app/components/viewer/action_modes.hbs b/app/components/viewer/action_modes.hbs new file mode 100644 index 0000000000000000000000000000000000000000..4a54b631d246688dcbc152bed4a7686c1f041956 --- /dev/null +++ b/app/components/viewer/action_modes.hbs @@ -0,0 +1,12 @@ +<div class="d-flex"> + <div class="panel-mode"> + <button type="button" class="btn btn-light mx-1" + {{on "click" (fn @onPanelToggle "document")}}> + {{#if @dualPanelMode}} + <i class="bi-x"></i> + {{else}} + <i class="bi-layout-split"></i> + {{/if}} + </button> + </div> +</div> \ No newline at end of file diff --git a/app/components/viewer/index.hbs b/app/components/viewer/index.hbs index 2b58a4e961f20b166b5d2535b37673ae676fb510..48fc96422dc3dcd4815783e38902b368300dd559 100644 --- a/app/components/viewer/index.hbs +++ b/app/components/viewer/index.hbs @@ -5,6 +5,10 @@ @isLocked={{this.isLocked}} @ocrStatus={{this.ocrStatus}} @onRunOCR={{this.onRunOCR}} /> + + <Viewer::ActionModes + @onPanelToggle={{@onPanelToggle}} + @dualPanelMode={{@dualPanelMode}} /> </div> <Breadcrumb diff --git a/app/controllers/authenticated/document.js b/app/controllers/authenticated/document.js index ea57177d4275d1732f22b8b70225e674a8efcd37..221d1010d04a8d5557b97fa7717f13f840f91db6 100644 --- a/app/controllers/authenticated/document.js +++ b/app/controllers/authenticated/document.js @@ -1,24 +1,33 @@ -import Controller from '@ember/controller'; import { action } from '@ember/object'; -import { tracked } from "@glimmer/tracking"; -import { inject as service } from '@ember/service'; +import DualPanelBaseController from "./dualpanel_base"; -export default class ViewerController extends Controller { - - @service currentUser; - - @tracked extranode_id = null; - @tracked extradoc_id = null; - - queryParams = ['extranode_id', 'extradoc_id'] +export default class DocumentController extends DualPanelBaseController { @action - async onPanelToggle() { + async onPanelToggle(origin) { + /* + origin is either "document" or "nodes" depending where + the onPanelToggle originated from. + */ let home_folder; if (this.extranode_id) { - this.extranode_id = null; + /* + Here we have document viewer as main panel (left) and nodes panel as + extra (on the right). + */ + if (origin === "document") { + // user decided to close document panel + this.replaceRoute('authenticated.nodes', this.extranode_id); + this.extranode_id = null; + } else if (origin === "nodes") { + // User decided to close nodes extra panel. + // He/She decided to view only the document + this.extranode_id = null; + } else { + throw `Unknown value for origin argument: ${origin}`; + } } else { home_folder = await this.currentUser.user.home_folder; this.extranode_id = home_folder.get('id'); diff --git a/app/controllers/authenticated/dualpanel_base.js b/app/controllers/authenticated/dualpanel_base.js new file mode 100644 index 0000000000000000000000000000000000000000..7aab372a7be4fd88ff994012b0d59cd22438e453 --- /dev/null +++ b/app/controllers/authenticated/dualpanel_base.js @@ -0,0 +1,31 @@ +import Controller from '@ember/controller'; +import { action } from '@ember/object'; +import { tracked } from "@glimmer/tracking"; +import { inject as service } from '@ember/service'; + + +export default class DualPanelBaseController extends Controller { + + @service currentUser; + + @tracked extranode_id = null; + @tracked extradoc_id = null; + + queryParams = ['extranode_id', 'extradoc_id'] + + @action + async onPanelToggle() { + let home_folder; + + if (this.extranode_id) { + this.extranode_id = null; + } else { + home_folder = await this.currentUser.user.home_folder; + this.extranode_id = home_folder.get('id'); + } + } + + get dualpanel_mode() { + return this.extranode_id || this.extradoc_id; + } +} diff --git a/app/controllers/authenticated/nodes.js b/app/controllers/authenticated/nodes.js index 85588d09a162550bacedc360c8c3d78cf5c7d649..75a830243e544766059b40b065907ff3ce71daf1 100644 --- a/app/controllers/authenticated/nodes.js +++ b/app/controllers/authenticated/nodes.js @@ -1,25 +1,6 @@ -import Controller from '@ember/controller'; -import { action } from '@ember/object'; -import { tracked } from "@glimmer/tracking"; -import { inject as service } from '@ember/service'; +import DualPanelBaseController from "./dualpanel_base"; -export default class NodesController extends Controller { +export default class NodesController extends DualPanelBaseController { - @service currentUser; - @tracked extranode_id = null; - @tracked extradoc_id = null; - queryParams = ['extranode_id', 'extradoc_id'] - - @action - async onPanelToggle() { - let home_folder; - - if (this.extranode_id) { - this.extranode_id = null; - } else { - home_folder = await this.currentUser.user.home_folder; - this.extranode_id = home_folder.get('id'); - } - } } diff --git a/app/routes/authenticated/document.js b/app/routes/authenticated/document.js index 22bf95ff97755cdca530069a44b603b9e2f1b174..5701156145494e1e1e1116db4d2234ac0628569a 100644 --- a/app/routes/authenticated/document.js +++ b/app/routes/authenticated/document.js @@ -29,7 +29,7 @@ export default class DocumentRoute extends Route { page_adapter = this.store.adapterFor('page'); - doc = await this.store.findRecord( + doc = await this.store.findRecord( 'document', params.document_id, { reload: true } @@ -73,9 +73,15 @@ export default class DocumentRoute extends Route { }); return { - 'document_version': last_version, + 'doc': doc, + 'document_versions': doc.versions, + 'last_document_version': last_version, 'pages': pages_with_url, - 'extranode': extranode + 'extra': { + 'current_node':extranode.current_node, + 'children':extranode.children, + 'pagination':extranode.pagination + } }; } @@ -86,8 +92,4 @@ export default class DocumentRoute extends Route { 'pages': pages_with_url }; } - - renderTemplate() { - this.render('authenticated.viewer'); - } } diff --git a/app/routes/authenticated/nodes.js b/app/routes/authenticated/nodes.js index c290e499daf11134a3fa24d5ab329f1ab92eb4f0..268ace682cc23caecf69dbbb9cecb7f064385094 100644 --- a/app/routes/authenticated/nodes.js +++ b/app/routes/authenticated/nodes.js @@ -47,6 +47,7 @@ export default class FolderRoute extends Route { document_version = await doc_adapter.getDocumentVersion(params.extradoc_id); pages = await document_version.pages; pages_with_url = await page_adapter.loadBinaryImages(pages); + this.dualpanel_mode = true; return RSVP.hash({ node: adapter.findNode(params.node_id), @@ -62,6 +63,7 @@ export default class FolderRoute extends Route { node_id: params.extranode_id, page: 1 }); + this.dualpanel_mode = true; } context['home_folder'] = await this.currentUser.user.getHomeFolder(); @@ -75,15 +77,12 @@ export default class FolderRoute extends Route { _auth_controller = this.controllerFor('authenticated'); if (model.extranode) { - _controller.set('dualpanel_mode', true); _controller.set('extranode', model.extranode); } else if (model.document_version) { - _controller.set('dualpanel_mode', true); _controller.set('document_version', model.document_version); _controller.set('pages', model.pages); _controller.set('extranode', model.document_version.document); } else { - _controller.set('dualpanel_mode', false); _controller.set('extranode', undefined); } _controller.set('mainnode', model.current_node); diff --git a/app/templates/authenticated/viewer.hbs b/app/templates/authenticated/document.hbs similarity index 81% rename from app/templates/authenticated/viewer.hbs rename to app/templates/authenticated/document.hbs index 5436ccbae7eb267d070c9f3f8397925777e9a8a5..3d551f08803d0e0d7fc42b0874c7184229355934 100644 --- a/app/templates/authenticated/viewer.hbs +++ b/app/templates/authenticated/document.hbs @@ -18,10 +18,10 @@ @hint="right" /> {{else}} <Commander - @node={{this.extranode.current_node}} - @children={{this.extranode.children}} - @pagination={{this.extranode.pagination}} - @extradoc={{@model}} + @node={{@model.extra.current_node}} + @children={{@model.extra.children}} + @pagination={{@model.extra.pagination}} + @extradoc={{@model.doc}} @onPanelToggle={{this.onPanelToggle}} @dualPanelMode={{this.dualpanel_mode}} @hint="right" /> diff --git a/config/environment.js b/config/environment.js index a0e1e99c1204b216241a100181d4285a697fa65b..f87a1e6ea0a144df26998f4ac40c4b5bec6500e7 100644 --- a/config/environment.js +++ b/config/environment.js @@ -33,6 +33,7 @@ module.exports = function (environment) { // ENV.APP.LOG_TRANSITIONS = true; // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; // ENV.APP.LOG_VIEW_LOOKUPS = true; + ENV['ember-cli-mirage'] = { enabled: false}; } if (environment === 'test') { @@ -47,9 +48,7 @@ module.exports = function (environment) { ENV.APP.autoboot = false; // enable migrage - which mocks HTTP requests - ENV['ember-cli-mirage'] = { - enabled: true, - }; + ENV['ember-cli-mirage'] = { enabled: true }; } if (environment === 'production') {