Resolving som conflicts from merge

This commit is contained in:
Knut Sveidqvist
2019-06-11 08:35:46 -07:00
4 changed files with 110 additions and 43 deletions

View File

@@ -96,12 +96,14 @@ export const addLink = function (start, end, type, linktext) {
* @param pos * @param pos
* @param interpolate * @param interpolate
*/ */
export const updateLinkInterpolate = function (pos, interp) { export const updateLinkInterpolate = function (positions, interp) {
positions.forEach(function (pos) {
if (pos === 'default') { if (pos === 'default') {
edges.defaultInterpolate = interp edges.defaultInterpolate = interp
} else { } else {
edges[pos].interpolate = interp edges[pos].interpolate = interp
} }
})
} }
/** /**
@@ -109,7 +111,8 @@ export const updateLinkInterpolate = function (pos, interp) {
* @param pos * @param pos
* @param style * @param style
*/ */
export const updateLink = function (pos, style) { export const updateLink = function (positions, style) {
positions.forEach(function (pos) {
if (pos === 'default') { if (pos === 'default') {
edges.defaultStyle = style edges.defaultStyle = style
} else { } else {
@@ -118,6 +121,7 @@ export const updateLink = function (pos, style) {
} }
edges[pos].style = style edges[pos].style = style
} }
})
} }
export const addClass = function (id, style) { export const addClass = function (id, style) {

View File

@@ -414,21 +414,27 @@ styleStatement:STYLE SPACE alphaNum SPACE stylesOpt
linkStyleStatement linkStyleStatement
: LINKSTYLE SPACE DEFAULT SPACE stylesOpt : LINKSTYLE SPACE DEFAULT SPACE stylesOpt
{$$ = $1;yy.updateLink($3,$5);} {$$ = $1;yy.updateLink([$3],$5);}
| LINKSTYLE SPACE NUM SPACE stylesOpt | LINKSTYLE SPACE numList SPACE stylesOpt
{$$ = $1;yy.updateLink($3,$5);} {$$ = $1;yy.updateLink($3,$5);}
| LINKSTYLE SPACE DEFAULT SPACE INTERPOLATE SPACE alphaNum SPACE stylesOpt | LINKSTYLE SPACE DEFAULT SPACE INTERPOLATE SPACE alphaNum SPACE stylesOpt
{$$ = $1;yy.updateLinkInterpolate($3,$7);yy.updateLink($3,$9);} {$$ = $1;yy.updateLinkInterpolate([$3],$7);yy.updateLink([$3],$9);}
| LINKSTYLE SPACE NUM SPACE INTERPOLATE SPACE alphaNum SPACE stylesOpt | LINKSTYLE SPACE numList SPACE INTERPOLATE SPACE alphaNum SPACE stylesOpt
{$$ = $1;yy.updateLinkInterpolate($3,$7);yy.updateLink($3,$9);} {$$ = $1;yy.updateLinkInterpolate($3,$7);yy.updateLink($3,$9);}
| LINKSTYLE SPACE DEFAULT SPACE INTERPOLATE SPACE alphaNum | LINKSTYLE SPACE DEFAULT SPACE INTERPOLATE SPACE alphaNum
{$$ = $1;yy.updateLinkInterpolate($3,$7);} {$$ = $1;yy.updateLinkInterpolate([$3],$7);}
| LINKSTYLE SPACE NUM SPACE INTERPOLATE SPACE alphaNum | LINKSTYLE SPACE numList SPACE INTERPOLATE SPACE alphaNum
{$$ = $1;yy.updateLinkInterpolate($3,$7);} {$$ = $1;yy.updateLinkInterpolate($3,$7);}
; ;
commentStatement: PCT PCT commentText; commentStatement: PCT PCT commentText;
numList: NUM
{$$ = [$1]}
| numList COMMA NUM
{$1.push($3);$$ = $1;}
;
stylesOpt: style stylesOpt: style
{$$ = [$1]} {$$ = [$1]}
| stylesOpt COMMA style | stylesOpt COMMA style

File diff suppressed because one or more lines are too long

View File

@@ -453,6 +453,28 @@ describe('when parsing ', function () {
expect(edges[0].type).toBe('arrow') expect(edges[0].type).toBe('arrow')
}) })
it('should handle multi-numbered style definitons with more then 1 digit in a row', function () {
const res = flow.parser.parse('graph TD\n' +
'A-->B1\n' +
'A-->B2\n' +
'A-->B3\n' +
'A-->B4\n' +
'A-->B5\n' +
'A-->B6\n' +
'A-->B7\n' +
'A-->B8\n' +
'A-->B9\n' +
'A-->B10\n' +
'A-->B11\n' +
'A-->B12\n' +
'linkStyle 10,11 stroke-width:1px;')
const vert = flow.parser.yy.getVertices()
const edges = flow.parser.yy.getEdges()
expect(edges[0].type).toBe('arrow')
})
it('should handle line interpolation default definitions', function () { it('should handle line interpolation default definitions', function () {
const res = flow.parser.parse('graph TD\n' + const res = flow.parser.parse('graph TD\n' +
'A-->B\n' + 'A-->B\n' +
@@ -478,6 +500,19 @@ describe('when parsing ', function () {
expect(edges[1].interpolate).toBe('cardinal') expect(edges[1].interpolate).toBe('cardinal')
}) })
it('should handle line interpolation multi-numbered definitions', function () {
const res = flow.parser.parse('graph TD\n' +
'A-->B\n' +
'A-->C\n' +
'linkStyle 0,1 interpolate basis')
const vert = flow.parser.yy.getVertices()
const edges = flow.parser.yy.getEdges()
expect(edges[0].interpolate).toBe('basis')
expect(edges[1].interpolate).toBe('basis')
})
it('should handle line interpolation default with style', function () { it('should handle line interpolation default with style', function () {
const res = flow.parser.parse('graph TD\n' + const res = flow.parser.parse('graph TD\n' +
'A-->B\n' + 'A-->B\n' +
@@ -503,6 +538,19 @@ describe('when parsing ', function () {
expect(edges[1].interpolate).toBe('cardinal') expect(edges[1].interpolate).toBe('cardinal')
}) })
it('should handle line interpolation multi-numbered with style', function () {
const res = flow.parser.parse('graph TD\n' +
'A-->B\n' +
'A-->C\n' +
'linkStyle 0,1 interpolate basis stroke-width:1px;')
const vert = flow.parser.yy.getVertices()
const edges = flow.parser.yy.getEdges()
expect(edges[0].interpolate).toBe('basis')
expect(edges[1].interpolate).toBe('basis')
})
describe('it should handle interaction, ', function () { describe('it should handle interaction, ', function () {
it('it should be possible to use click to a callback', function () { it('it should be possible to use click to a callback', function () {
spyOn(flowDb, 'setClickEvent') spyOn(flowDb, 'setClickEvent')