Skip to content

Commit

Permalink
fix(asana): Fix project selection in Asana integration
Browse files Browse the repository at this point in the history
Closes #1457.
  • Loading branch information
tcrammond authored and shantanuraj committed Jul 30, 2019
1 parent af8c809 commit e1e89f6
Showing 1 changed file with 11 additions and 133 deletions.
144 changes: 11 additions & 133 deletions src/scripts/content/asana.js
Original file line number Diff line number Diff line change
@@ -1,105 +1,5 @@
'use strict';

// Older UI
togglbutton.render(
'.details-pane-body:not(.toggl)',
{ observe: true },
function (elem) {
const container = $('.sticky-view-placeholder', elem);
const description = $('#details_property_sheet_title', elem);
const project = $('#details_pane_project_tokenizer .token_name', elem);

const descFunc = function () {
return description ? description.value : '';
};

const projectFunc = function () {
return (
(project && project.textContent) ||
($('.ancestor-projects', elem) &&
$('.ancestor-projects', elem).textContent) ||
''
);
};

const link = togglbutton.createTimerLink({
className: 'asana',
description: descFunc,
projectName: projectFunc
});

container.parentNode.insertBefore(link, container.nextSibling);
}
);

// New UI v1
togglbutton.render(
'#right_pane__contents .SingleTaskPane:not(.toggl)',
{ observe: true },
function (elem) {
const container = $('.SingleTaskTitleRow', elem);
const description = $('.SingleTaskTitleRow .simpleTextarea', elem);
const project = $('.TaskProjectPill-projectName div', elem);

if (!container) {
return;
}

const descFunc = function () {
return description ? description.value : '';
};

const projectFunc = function () {
return (
(project && project.textContent) ||
($('.TaskAncestry-ancestorProjects', elem) &&
$('.TaskAncestry-ancestorProjects', elem).textContent) ||
''
);
};

const link = togglbutton.createTimerLink({
className: 'asana-new',
description: descFunc,
projectName: projectFunc
});

container.after(link);
}
);

// New UI v2
togglbutton.render(
'#right_pane__contents .SingleTaskPane-body:not(.toggl)',
{ observe: true },
function (elem) {
const container = $('.TaskPaneAssigneeDueDateRowStructure', elem);
const description = $('.SingleTaskPane-titleRow .simpleTextarea', elem);
const project = $('.TaskProjectPill-projectName div', elem);

const descFunc = function () {
return description ? description.value : '';
};

const projectFunc = function () {
return (
(project && project.textContent) ||
($('.TaskAncestry-ancestorProjects', elem) &&
$('.TaskAncestry-ancestorProjects', elem).textContent) ||
''
);
};

const link = togglbutton.createTimerLink({
className: 'asana-new',
description: descFunc,
projectName: projectFunc
});

container.appendChild(link);
}
);

// New UI Board view v1 and v2
togglbutton.render(
'.BoardColumnCardsContainer-item:not(.toggl)',
Expand All @@ -123,32 +23,6 @@ togglbutton.render(
}
);

// New UI Board task detail view v1
togglbutton.render(
'.SingleTaskTitleRow:not(.toggl)',
{ observe: true },
function (elem) {
if ($('.toggl-button', elem)) {
return;
}
const container = $('.SingleTaskPaneToolbar', elem.parentNode);
const description = $('.SingleTaskTitleRow textarea', elem.parentNode).textContent;
const projectElement = $(
'.SingleTaskPane-projects .TaskProjectPill-projectName',
elem.parentNode
);

const link = togglbutton.createTimerLink({
className: 'asana-board',
description: description,
projectName: projectElement ? projectElement.textContent : '',
buttonType: 'minimal'
});

container.appendChild(link);
}
);

// New UI Board task detail view v2
togglbutton.render(
'.SingleTaskPane-titleRow:not(.toggl)',
Expand All @@ -159,22 +33,26 @@ togglbutton.render(
}
const container = $('.SingleTaskPaneToolbar');

const description = function () {
const descriptionSelector = () => {
return $(
'.SingleTaskPane-titleRow .simpleTextarea',
elem.parentNode
).textContent;
};

const projectElement = $(
'.SingleTaskPane-projects .TaskProjectPill-projectName',
elem.parentNode
);
const projectSelector = () => {
const projectElement = $(
'.SingleTaskPane-projects .TaskProjectPill-projectName',
elem.parentNode
);

return projectElement ? projectElement.textContent : '';
};

const link = togglbutton.createTimerLink({
className: 'asana-board',
description: description,
projectName: projectElement ? projectElement.textContent : '',
description: descriptionSelector,
projectName: projectSelector,
buttonType: 'minimal'
});

Expand Down

0 comments on commit e1e89f6

Please sign in to comment.