-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: #2 three classes migrated to typescript
- Loading branch information
Pawel Siemienik
committed
Feb 15, 2020
1 parent
92b1613
commit f1f5bb4
Showing
6 changed files
with
83 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BaseCell } from './BaseCell'; | ||
import { Cell, ValueType } from 'exceljs'; | ||
import { Scope } from '../Scope'; | ||
|
||
export class DeleteCell extends BaseCell { | ||
public static match(cell: Cell): boolean { | ||
return cell && cell.type === ValueType.String && typeof cell.value === 'string' && cell.value.substring(0, 9) === '#! DELETE'; | ||
} | ||
|
||
public apply(scope: Scope): DeleteCell { | ||
super.apply(scope); | ||
|
||
const target = scope.getCurrentTemplateValue()?.toString().split(' ')[2]; //todo make some function for scope.getCurrentTemplateValue()?.toString().split(' ') ; | ||
|
||
if (target == undefined) return this; //it's ok here | ||
|
||
scope.vm[target] = undefined; | ||
|
||
scope.setCurrentOutputValue(null); | ||
scope.incrementCol(); | ||
|
||
return this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { BaseCell } from './BaseCell'; | ||
import { Scope } from '../Scope'; | ||
import { Cell, ValueType } from 'exceljs'; | ||
|
||
export class HyperlinkCell extends BaseCell { | ||
public static match(cell: Cell): boolean { | ||
return cell && cell.type === ValueType.String && typeof cell.value === 'string' && cell.value.substring(0, 12) === '#! HYPERLINK'; | ||
} | ||
|
||
protected static getLabelParam(scope: Scope): string { | ||
return scope.getCurrentTemplateValue()?.toString().split(' ')[2] || ''; | ||
} | ||
|
||
protected static getUrlParam(scope: Scope): string { | ||
return scope.getCurrentTemplateValue()?.toString().split(' ')[3] || ''; | ||
} | ||
|
||
public apply(scope: Scope): HyperlinkCell { | ||
super.apply(scope); | ||
|
||
scope.setCurrentOutputValue(null); | ||
|
||
const url = HyperlinkCell.getUrlParam(scope).split('.').reduce((p, c) => p[c] || {}, scope.vm); | ||
if (typeof url === 'string') { | ||
const label = HyperlinkCell.getLabelParam(scope).split('.').reduce((p, c) => p[c] || {}, scope.vm) || url; | ||
console.log(label); | ||
scope.setCurrentOutputValue({ text: label, hyperlink: url }); | ||
} | ||
|
||
scope.incrementCol(); | ||
|
||
return this; | ||
} | ||
} |