Skip to content

Commit

Permalink
fix(wrike): Fix errors breaking the Wrike integration
Browse files Browse the repository at this point in the history
Closes #1388. Also integrates PR 1379.
  • Loading branch information
tcrammond authored and shantanuraj committed May 14, 2019
1 parent 792c6fe commit 13f683c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/scripts/content/wrike.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ togglbutton.render(
function (elem) {
const container = $('.wrike-panel-header-toolbar', elem);

const getTitleElement = function () {
const wsTaskTitle = document.querySelectorAll('ws-task-title');
if (wsTaskTitle.length === 1 && wsTaskTitle[0].textContent !== '') {
return wsTaskTitle[0];
}
return $('title');
};

const descriptionText = function () {
const urlString = window.location.href;
const url = new URL(urlString);
Expand All @@ -20,15 +28,15 @@ togglbutton.render(
}
}

const titleElem = $('.title-field-ghost', elem);
const titleElem = getTitleElement();
const titleElemText = titleElem ? titleElem.textContent : 'not found';
return `#${taskId} ${titleElemText.trim()}`;
return `${taskId ? '#' + taskId : ''} ${titleElemText.trim().replace(' - Wrike', '')}`.trim();
};

const projectText = function () {
const projectElem = $('.wspace-tag-simple', elem);
// We process the project element text content.
return projectElem.textContent;
return projectElem ? projectElem.textContent : '';
};

const link = togglbutton.createTimerLink({
Expand Down

0 comments on commit 13f683c

Please sign in to comment.