@dazn/kopytko-framework 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -148,7 +148,7 @@ function HttpRequest(options as Object, httpInterceptors = [] as Object) as Obje
|
|
|
148
148
|
|
|
149
149
|
' @returns {Boolean}
|
|
150
150
|
prototype.isCachingEnabled = function () as Boolean
|
|
151
|
-
return getProperty(m.
|
|
151
|
+
return getProperty(m._options, "enableCaching", true)
|
|
152
152
|
end function
|
|
153
153
|
|
|
154
154
|
prototype.setHeader = sub (name as String, value as Dynamic)
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
' @import /components/buildUrl.brs from @dazn/kopytko-utils
|
|
2
2
|
' @import /components/getProperty.brs from @dazn/kopytko-utils
|
|
3
3
|
' @import /components/NodeUtils.brs from @dazn/kopytko-utils
|
|
4
|
-
' @import /components/ternary.brs from @dazn/kopytko-utils
|
|
5
4
|
' @import /components/utils/KopytkoGlobalNode.brs
|
|
5
|
+
|
|
6
6
|
sub init()
|
|
7
7
|
_global = KopytkoGlobalNode()
|
|
8
8
|
_global.addFields({
|
|
9
9
|
router: m.top,
|
|
10
10
|
})
|
|
11
|
-
m.top.activatedRoute =
|
|
11
|
+
m.top.activatedRoute = _createRoute()
|
|
12
12
|
|
|
13
13
|
m._history = []
|
|
14
14
|
end sub
|
|
15
15
|
|
|
16
|
-
sub navigate(
|
|
17
|
-
url = buildUrl(
|
|
16
|
+
sub navigate(navigateData as Object)
|
|
17
|
+
url = buildUrl(navigateData.path, navigateData.params)
|
|
18
18
|
if (url = m.top.url) then return ' Avoid doubling url
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
isBackJourney = getProperty(navigateData, "isBackJourney", false)
|
|
21
|
+
|
|
22
|
+
if (NOT getProperty(navigateData, "skipInHistory", false))
|
|
21
23
|
_updateHistory()
|
|
22
24
|
end if
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end if
|
|
26
|
+
' Needs to be set before activatedRoute as _getPreviousRoute uses the previous value of activatedRoute.
|
|
27
|
+
m.top.previousRoute = _getPreviousRoute(isBackJourney)
|
|
27
28
|
|
|
28
|
-
m.top.activatedRoute.path =
|
|
29
|
-
m.top.activatedRoute.params =
|
|
30
|
-
m.top.activatedRoute.backJourneyData =
|
|
31
|
-
m.top.activatedRoute.isBackJourney =
|
|
29
|
+
m.top.activatedRoute.path = getProperty(navigateData, "path", "")
|
|
30
|
+
m.top.activatedRoute.params = getProperty(navigateData, "params", {})
|
|
31
|
+
m.top.activatedRoute.backJourneyData = navigateData.backJourneyData
|
|
32
|
+
m.top.activatedRoute.isBackJourney = isBackJourney
|
|
32
33
|
m.top.activatedRoute.shouldSkip = false
|
|
33
|
-
m.top.activatedRoute.virtualPath = ""
|
|
34
|
+
m.top.activatedRoute.virtualPath = getProperty(navigateData, "virtualPath", "")
|
|
34
35
|
m.top.url = url
|
|
35
36
|
end sub
|
|
36
37
|
|
|
37
|
-
function back(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end if
|
|
38
|
+
function back(_backData = {} as Object) as Boolean
|
|
39
|
+
previousRoute = m._history.pop()
|
|
40
|
+
|
|
41
|
+
if (previousRoute = Invalid) then return false
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
navigate(
|
|
43
|
+
previousRoute.skipInHistory = true
|
|
44
|
+
previousRoute.isBackJourney = true
|
|
45
|
+
navigate(previousRoute)
|
|
46
46
|
|
|
47
47
|
return true
|
|
48
48
|
end function
|
|
@@ -51,22 +51,25 @@ sub resetHistory(rootPath = "" as String)
|
|
|
51
51
|
m._history = []
|
|
52
52
|
|
|
53
53
|
if (rootPath <> "")
|
|
54
|
-
m._history.push({ path: rootPath
|
|
54
|
+
m._history.push(_createRoute({ path: rootPath }))
|
|
55
55
|
end if
|
|
56
56
|
end sub
|
|
57
57
|
|
|
58
|
+
function _getPreviousRoute(isBackJourney as Boolean) as Object
|
|
59
|
+
if (isBackJourney OR m.top.activatedRoute.shouldSkip) then return m._history.peek()
|
|
60
|
+
|
|
61
|
+
return NodeUtils().cloneNode(m.top.activatedRoute)
|
|
62
|
+
end function
|
|
63
|
+
|
|
58
64
|
sub _updateHistory()
|
|
59
|
-
if (m.top.url = "" OR m.top.activatedRoute.shouldSkip)
|
|
60
|
-
return
|
|
61
|
-
end if
|
|
65
|
+
if (m.top.url = "" OR m.top.activatedRoute.shouldSkip) then return
|
|
62
66
|
|
|
63
|
-
m._history.push(
|
|
67
|
+
m._history.push(NodeUtils().cloneNode(m.top.activatedRoute))
|
|
64
68
|
end sub
|
|
65
69
|
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
70
|
+
function _createRoute(routeData = {} as Object) as Object
|
|
71
|
+
route = CreateObject("roSGNode", "ActivatedRoute")
|
|
72
|
+
route.setFields(routeData)
|
|
73
|
+
|
|
74
|
+
return route
|
|
72
75
|
end function
|