From fda2704fc864bdec154e73bb1ca7505bfe7fa9ba Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sat, 28 Aug 2021 15:20:10 -0500 Subject: [PATCH] Add tooltips to files in tree view. (#2894) * Makes the two buttons (stage/unstage) separate so the template file has all the title etc in it. * Hides/unhides to show the appropriate button only. --- static/panes/tree.ts | 40 ++++++++++++++++++---------------------- views/templates.pug | 7 ++++--- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/static/panes/tree.ts b/static/panes/tree.ts index 2c0ce72d3..a6171f02d 100644 --- a/static/panes/tree.ts +++ b/static/panes/tree.ts @@ -22,9 +22,8 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import { MultifileFile, MultifileService, MultifileServiceState } from "../multifile-service"; -import { saveAs } from "file-saver"; -import { LineColouring } from "../line-colouring"; +import {MultifileFile, MultifileService, MultifileServiceState} from '../multifile-service'; +import {LineColouring} from '../line-colouring'; const _ = require('underscore'); const $ = require('jquery'); @@ -39,7 +38,7 @@ const languages = options.languages; const saveAs = require('file-saver').saveAs; export class TreeState extends MultifileServiceState { - id: number + id: number; cmakeArgs: string; customOutputFilename: string; } @@ -179,8 +178,8 @@ export class Tree { id: this.id, cmakeArgs: this.getCmakeArgs(), customOutputFilename: this.getCustomOutputFilename(), - ... this.multifileService.getState() - } + ...this.multifileService.getState(), + }; }; private updateState() { @@ -317,7 +316,8 @@ export class Tree { private addRowToTreelist(file: MultifileFile) { const item = $(this.rowTemplate.children()[0].cloneNode(true)); - const stagingButton = item.find('.stage-file'); + const stageButton = item.find('.stage-file'); + const unstageButton = item.find('.unstage-file'); const renameButton = item.find('.rename-file'); const deleteButton = item.find('.delete-file'); @@ -359,21 +359,17 @@ export class Tree { } }); - if (file.isIncluded) { - stagingButton.removeClass('fa-plus').addClass('fa-minus'); - stagingButton.on('click', async (e) => { - const fileId = $(e.currentTarget).parent('li').data('fileId'); - await this.moveToExclude(fileId); - }); - this.namedItems.append(item); - } else { - stagingButton.removeClass('fa-minus').addClass('fa-plus'); - stagingButton.on('click', async (e) => { - const fileId = $(e.currentTarget).parent('li').data('fileId'); - await this.moveToInclude(fileId); - }); - this.unnamedItems.append(item); - } + stageButton.on('click', async (e) => { + const fileId = $(e.currentTarget).parent('li').data('fileId'); + await this.moveToInclude(fileId); + }); + unstageButton.on('click', async (e) => { + const fileId = $(e.currentTarget).parent('li').data('fileId'); + await this.moveToExclude(fileId); + }); + stageButton.toggle(!file.isIncluded); + unstageButton.toggle(file.isIncluded); + (file.isIncluded ? this.namedItems : this.unnamedItems).append(item); } private refresh() { diff --git a/views/templates.pug b/views/templates.pug index 7b5165a4f..ddb249c2f 100644 --- a/views/templates.pug +++ b/views/templates.pug @@ -478,6 +478,7 @@ #tree-editor-tpl li.list-group-item.tree-editor-file.input-group-append span.filename someresource.txt - button.btn.delete-file.fa.fa-trash - button.btn.rename-file.fa.fa-tag - button.btn.stage-file.fa.fa-plus + button.btn.delete-file.fa.fa-trash(title="Remove this file" aria-label="Delete") + button.btn.rename-file.fa.fa-tag(title="Rename this file" aria-label="Rename") + button.btn.stage-file.fa.fa-plus(title="Include this file in the build" aria-label="Include") + button.btn.unstage-file.fa.fa-minus(title="Exclude this file from the build" aria-label="Exclude")