Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 155 additions & 5 deletions dist/chrome/js/components/options-app.js

Large diffs are not rendered by default.

40 changes: 27 additions & 13 deletions dist/chrome/js/components/popup-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function createPopupAppTemplate(app, bdom, helpers) {
const readMoreProject = app.createComponent('ReadMore', true, false, false, ['text', 'limit']);

const rootBlock = createBlock(
`<div class="app-root"><div id="loader-container" block-attribute-0="class"><div class="loader-card"><div class="loader-text">Loading current session and projects…</div><div class="loader-subtext">Please wait — or grab a cup of coffee ☕</div><i class="fa fa-cog fa-spin fa-5x"/></div></div><div id="login" class="login-view" block-attribute-1="class"><div class="popup-login-shell"><div class="form"><div class="logo"><img src="/img/logo.png"/></div><block-child-0/><block-child-1/><block-child-2/></div></div><div class="cta forgotpwd footer-app-opts login-footer-bar"><a href="options_main_page.html"><i class="fa fa-cogs"/> Options</a></div></div><div id="wrapper" block-attribute-2="class"><div class="toolbar-row"><input id="searchIssue" type="text" placeholder="Search by ID, name, user, priority, stage..." block-property-3="value" block-handler-4="input"/><select id="limitTo" block-property-5="value" block-handler-6="change"><option value="10">10</option><option value="15">15</option><option value="25">25</option><option value="">All</option></select></div><div class="container footer top-actions"><div class="auto_download_timesheet" title="Store timesheet locally when you stop timer on the current item"><input id="auto_download_timesheet_input" type="checkbox" block-property-7="checked" block-handler-8="change"/> Auto Download Current Item Timesheet </div><div class="row"><div class="mx-3 col-md-12 footer-btns pointer"><i class="fa fa-download fa-2x" title="Download current month timesheet" block-handler-9="click"/><i class="fa fa-hand-o-left fa-2x" title="Switch between remotes" block-handler-10="click"/><i class="fa fa-refresh fa-2x" title="Refresh current items" block-handler-11="click"/><i class="fa fa-undo fa-2x" title="Discard the active timer" block-handler-12="click"/><i class="fa fa-sign-out fa-2x" title="Log out" block-handler-13="click"/><a href="options_main_page.html" class="options-btn" title="Go To options"><i class="fa fa-cogs fa-2x"/></a></div></div></div><div class="table-scroll"><table class="table table-responsive-sm table-bordered table-fixed" id="table-task-issues"><thead><tr><th class="action-col"><div><block-child-3/></div><block-child-4/></th><th class="priority-col">Priority</th><th class="stage-col">Stage</th><th class="item-col"><div class="item-header-title"><block-text-14/> [<block-text-15/>]</div><label class="allIssues"><input id="showAllIssues" type="checkbox" block-property-16="checked" block-handler-17="input"/> Show for everyone</label></th><block-child-5/><block-child-6/><th class="project-col">Project</th></tr></thead><tbody><block-child-7/><block-child-8/></tbody></table></div><div class="info-footer mx-3"><div class="row"><div class="remote-info-block col-md-12"><span><b>Odoo:</b> <block-text-18/></span><br/><span><b>Host:</b> <block-text-19/></span><br/><span><b>Database:</b> <block-text-20/></span><br/><span><b>Current User:</b> <block-text-21/></span><br/></div></div></div></div></div>`
`<div class="app-root"><div id="loader-container" block-attribute-0="class"><div class="loader-card"><div class="loader-text">Loading current session and projects…</div><div class="loader-subtext">Please wait — or grab a cup of coffee ☕</div><i class="fa fa-cog fa-spin fa-5x"/></div></div><div id="login" class="login-view" block-attribute-1="class"><div class="popup-login-shell"><div class="form"><div class="logo"><img src="/img/logo.png"/></div><block-child-0/><block-child-1/><block-child-2/></div></div><div class="cta forgotpwd footer-app-opts login-footer-bar"><a href="options_main_page.html"><i class="fa fa-cogs"/> Options</a></div></div><div id="wrapper" block-attribute-2="class"><div class="toolbar-row"><input id="searchIssue" type="text" placeholder="Search by ID, name, user, priority, stage..." block-property-3="value" block-handler-4="input"/><select id="limitTo" block-property-5="value" block-handler-6="change"><option value="10">10</option><option value="15">15</option><option value="25">25</option><option value="">All</option></select></div><div class="container footer top-actions"><div class="row"><div class="mx-3 col-md-12 footer-btns pointer"><i class="fa fa-download fa-2x" title="Download current month timesheet" block-handler-7="click"/><i class="fa fa-hand-o-left fa-2x" title="Switch between remotes" block-handler-8="click"/><i class="fa fa-refresh fa-2x" title="Refresh current items" block-handler-9="click"/><i class="fa fa-undo fa-2x" title="Discard the active timer" block-handler-10="click"/><i class="fa fa-sign-out fa-2x" title="Log out" block-handler-11="click"/><a href="options_main_page.html" class="options-btn" title="Go To options"><i class="fa fa-cogs fa-2x"/></a></div></div></div><div class="table-scroll"><table class="table table-responsive-sm table-bordered table-fixed" id="table-task-issues"><thead><tr><th class="action-col"><div><block-child-3/></div><block-child-4/></th><th class="priority-col">Priority</th><th class="stage-col">Stage</th><th class="item-col"><div class="item-header-title"><block-text-12/> [<block-text-13/>]</div><label class="allIssues"><input id="showAllIssues" type="checkbox" block-property-14="checked" block-handler-15="input"/> Show for everyone</label></th><block-child-5/><block-child-6/><th class="project-col">Project</th></tr></thead><tbody><block-child-7/><block-child-8/></tbody></table></div><div class="info-footer mx-3"><div class="row"><div class="remote-info-block col-md-12"><span><b>Odoo:</b> <block-text-16/></span><br/><span><b>Host:</b> <block-text-17/></span><br/><span><b>Database:</b> <block-text-18/></span><br/><span><b>Current User:</b> <block-text-19/></span><br/></div></div></div></div></div>`
);
const bootErrorBlock = createBlock(`<div><p class="odooError"><block-text-0/></p></div>`);
const noRemotesBlock = createBlock(
Expand All @@ -106,8 +106,8 @@ function createPopupAppTemplate(app, bdom, helpers) {
`<div class="remote-info small-note">Host: <block-text-0/> <span class="current-source-chip"><block-text-1/></span></div>`
);
const activeTimerDurationBlock = createBlock(`<span class="startTimeCount"><block-text-0/></span>`);
const hoursSpentHeaderBlock = createBlock(`<th>Hours Spent</th>`);
const remainingHoursHeaderBlock = createBlock(`<th>Remaining Hours</th>`);
const hoursSpentHeaderBlock = createBlock(`<th class="text-center">Hours Spent</th>`);
const remainingHoursHeaderBlock = createBlock(`<th class="text-center">Hours Left</th>`);
const issueRowBlock = createBlock(
`<tr block-attribute-0="class"><td class="text-center px-2 td-btn action-col"><block-child-0/><block-child-1/></td><td class="priority-cell"><block-child-2/><block-child-3/></td><td class="stage-cell"><block-child-4/></td><td class="issue-desc-cell"><block-child-5/></td><block-child-6/><block-child-7/><td class="project-cell"><block-child-8/></td></tr>`
);
Expand All @@ -119,8 +119,8 @@ function createPopupAppTemplate(app, bdom, helpers) {
);
const priorityStarBlock = createBlock(`<span class="fa fa-star checked"/>`);
const priorityStarOutlineBlock = createBlock(`<i class="fa fa-star-o"/>`);
const effectiveHoursCellBlock = createBlock(`<td><block-child-0/></td>`);
const remainingHoursCellBlock = createBlock(`<td><block-child-0/></td>`);
const effectiveHoursCellBlock = createBlock(`<td class="text-center"><block-child-0/></td>`);
const remainingHoursCellBlock = createBlock(`<td class="text-center"><block-child-0/></td>`);
const emptyIssuesRowBlock = createBlock(
`<tr><td block-attribute-0="colspan" class="text-center text-danger">No matching items are currently available</td></tr>`
);
Expand Down Expand Up @@ -250,8 +250,6 @@ function createPopupAppTemplate(app, bdom, helpers) {
const limitHandler = [(ev) => {
ctx.updateLimitPreference(ev.target.value);
}];
const autoDownloadChecked = ctx.state.autoDownloadIssueTimesheet;
const autoDownloadHandler = [ctx.toggleAutoDownload, ctx];
const downloadTimesheetHandler = [ctx.downloadCurrentMonthTimesheets, ctx];
const switchRemotesHandler = [ctx.switchBetweenRemotes, ctx];
const refreshHandler = [ctx.refreshAll, ctx];
Expand Down Expand Up @@ -400,8 +398,6 @@ function createPopupAppTemplate(app, bdom, helpers) {
searchQueryHandler,
limitValue,
limitHandler,
autoDownloadChecked,
autoDownloadHandler,
downloadTimesheetHandler,
switchRemotesHandler,
refreshHandler,
Expand Down Expand Up @@ -845,15 +841,15 @@ class PopupApp extends Component {
}

issueLabel(issue) {
const issueName = this.normalizeText(
issue.display_name || issue.name || issue.message_summary || issue.description || ''
);

if (this.state.dataSource === DATA_SOURCE_TASK) {
const code = this.normalizeText(issue.code);
const issueName = this.normalizeText(issue.name || issue.description || '');
return [code, issueName].filter(Boolean).join(' - ') || `#${issue.id}`;
}

const issueName = this.normalizeText(
issue.display_name || issue.name || issue.message_summary || issue.description || ''
);
return [`#${issue.id}`, issueName].filter(Boolean).join(' - ');
}

Expand Down Expand Up @@ -1291,6 +1287,24 @@ class PopupApp extends Component {
* Download a CSV with current month timesheet rows.
*/
async downloadCurrentMonthTimesheets() {
const autoDownloadEnabled = await storage.get('auto_download_issue_timesheet', false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit confusing. the function is downloadCurrentMonthTimesheets
returns early if auto_download_issue_timesheet is false

If auto_download_issue_timesheet should be called allow_download_issue_timesheet? there is nothing "auto" about it , its just allow/dissallow download.

if (!autoDownloadEnabled) {
const blockingText =
'<div style="text-align: center; padding: 20px;">' +
'<h5 style="margin-bottom: 15px; color: #d32f2f;">⚠️ Auto-Download Not Enabled</h5>' +
'<p style="margin-bottom: 15px; font-size: 16px;">' +
'Please enable <b>Auto Download Current Item Timesheet</b> ' +
'in the Options menu before downloading timesheets.' +
'</p>' +
'<p style="color: #666; font-size: 14px;">' +
'Click the <b>⚙️ Options</b> icon, then check the box under General Settings.' +
'</p>' +
'</div>';

await alert.show(blockingText, ['OK']);
return; // STOP - do not proceed with download
}

try {
if (!this.state.user?.id) {
throw new Error('Login first.');
Expand Down
Loading
Loading