Skip to content

Commit

Permalink
Merge pull request #125 from santeacademie/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-k authored Apr 3, 2023
2 parents 6773b40 + 94729b4 commit d8c03a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ class ContentStudioTools extends TamperController {

run = (request: TamperRequest): void => {
this.controllerKey = request.routeName;

this.csBridge = WssqlBridge.connect(WssqlRemoteDatabase.ContentStudio);
this.bsBridge = WssqlBridge.connect(WssqlRemoteDatabase.Backstage);

this.dealSyncAction(request);
};

dealSyncAction = (request: TamperRequest) => {
const checkKey = `${this.controllerKey}_dealSyncAction`;
const getAnchorEmail = () => {
return $('[data-test=email-label]:visible').eq(0);
return PipedriveHelper.getCustomFieldValueElementByName('E-mail').find('a').first();
};
const getAnchorSession = () => {
return PipedriveHelper.getCustomFieldValueElementByName('Session');
Expand All @@ -38,7 +40,7 @@ class ContentStudioTools extends TamperController {
this.checkFor(
checkKey,
() => {
return getAnchorSession().length !== 0 && getAnchorEmail().length !== 0 && document.location.href.match('/deal/');
return getAnchorEmail().text().trim() !== '' && getAnchorSession().text().trim() !== '' && document.location.href.match('/deal/');
},
(elementMarker: ElementMarkerCallback): DealCheckPayload => {
const $anchorEmail = getAnchorEmail();
Expand Down
9 changes: 5 additions & 4 deletions src/lib/controller/Pipedrive/PipedriveHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import $ from 'jquery';

class PipedriveHelper {
static getCustomFieldValueElementByName = (label: string): JQuery => {
return $('[data-test=field-label]:visible')
return $('[data-testid=field-name]:visible')
.filter(function () {
return $(this).text().trim() == label;
})
.eq(0)
.parents('.editable')
.find('.value');
.first()
.parents('[data-testid=fields-list-row]')
.find('[data-testid=fields-list-row-field-components] div')
.first();
};

static getBadgeValueView = (id: string, value: any): string => {
Expand Down

0 comments on commit d8c03a0

Please sign in to comment.