| 1 | /* |
| 2 | Copyright - 2017 2023 - wwwouaiebe - Contact: https://www.ouaie.be/ |
| 3 | |
| 4 | This program is free software; |
| 5 | you can redistribute it and/or modify it under the terms of the |
| 6 | GNU General Public License as published by the Free Software Foundation; |
| 7 | either version 3 of the License, or any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | /* |
| 19 | Changes: |
| 20 | - v4.0.0: |
| 21 | - created from v3.6.0 |
| 22 | Doc reviewed 202208 |
| 23 | */ |
| 24 | |
| 25 | import DockableBaseDialog from '../baseDialog/DockableBaseDialog.js'; |
| 26 | import theTranslator from '../../core/uiLib/Translator.js'; |
| 27 | import theNoteHTMLViewsFactory from '../../viewsFactories/NoteHTMLViewsFactory.js'; |
| 28 | import SortableListControl from '../../controls/sortableListControl/SortableListControl.js'; |
| 29 | import NoteContextMenu from '../../contextMenus/NoteContextMenu.js'; |
| 30 | import theConfig from '../../data/Config.js'; |
| 31 | import theNoteEditor from '../../core/NoteEditor.js'; |
| 32 | |
| 33 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
| 34 | /** |
| 35 | This class is the TravelNotesDialog |
| 36 | */ |
| 37 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
| 38 | |
| 39 | class TravelNotesDialog extends DockableBaseDialog { |
| 40 | |
| 41 | /** |
| 42 | The notes control |
| 43 | @type {SortableListControl} |
| 44 | */ |
| 45 | |
| 46 | #travelNotesControl; |
| 47 | |
| 48 | /** |
| 49 | The constructor |
| 50 | */ |
| 51 | |
| 52 | constructor ( ) { |
| 53 | super ( theConfig.travelNotesDialog.dialogX, theConfig.travelNotesDialog.dialogY ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | Create all the controls needed for the dialog. |
| 58 | Overload of the base class createContentHTML |
| 59 | */ |
| 60 | |
| 61 | createContentHTML ( ) { |
| 62 | this.#travelNotesControl = new SortableListControl ( |
| 63 | theNoteEditor.travelNoteDropped, |
| 64 | NoteContextMenu |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | An array with the HTMLElements that have to be added in the content of the dialog. |
| 70 | Overload of the BaseDialog contentHTMLElements property. |
| 71 | @type {Array.<HTMLElement>} |
| 72 | */ |
| 73 | |
| 74 | get contentHTMLElements ( ) { |
| 75 | return [ this.#travelNotesControl.controlHTMLElement ]; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | The dialog title. Overload of the BaseDialog.title property |
| 80 | @type {String} |
| 81 | */ |
| 82 | |
| 83 | get title ( ) { return theTranslator.getText ( 'TravelNotesDialog - Travel notes dialog' ); } |
| 84 | |
| 85 | /** |
| 86 | Update the content of the dialog |
| 87 | */ |
| 88 | |
| 89 | updateContent ( ) { |
| 90 | if ( ! this.#travelNotesControl ) { |
| 91 | return; |
| 92 | } |
| 93 | let travelNotesDiv = theNoteHTMLViewsFactory.getTravelNotesHTML ( 'TravelNotes-TravelNotesDialog-' ); |
| 94 | |
| 95 | // !!! Using travelNotesDiv.childNodes without Array.from gives strange results. |
| 96 | this.#travelNotesControl.updateContent ( Array.from ( travelNotesDiv.childNodes ) ); |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | |
| 101 | export default TravelNotesDialog; |
| 102 | |
| 103 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
| 104 |