Skip to content

Commit

Permalink
Added vicpol form redirect into core (#405)
Browse files Browse the repository at this point in the history
* Added vicpol form redirect into core

* poc for extends
  • Loading branch information
tim-yao committed Jul 1, 2019
1 parent f2765d8 commit aea4394
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
14 changes: 14 additions & 0 deletions examples/vic-gov-au/components/MyButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<div>This is custom template if needed</div>
</template>

<script>
import RplButton from '@dpc-sdp/ripple-button'
export default {
extends: RplButton,
name: 'MyButton',
created: function () {
console.log('This works.')
}
}
</script>
15 changes: 15 additions & 0 deletions examples/vic-gov-au/pages/my-page.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div>
<h1>This is a test</h1>
<my-button href="#" theme="primary" >My Button</my-button>
</div>
</template>

<script>
import MyButton from './../components/MyButton'
export default {
components: {
MyButton
}
}
</script>
34 changes: 34 additions & 0 deletions packages/ripple-nuxt-tide/lib/components/AppForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export default {
message: this.formData.messages.success || this.messages.success
}
}
// TODO: vicpol support, need to be reviewed when we add this feature into SDP.
this.vicPolRedirect()
} else {
this.formData.formState = {
response: {
Expand All @@ -78,6 +80,38 @@ export default {
}
}
}
},
// TODO: vicpol support, need to be reviewed when we add this feature into SDP.
vicPolRedirect: function () {
const getBrowserInfo = function () {
let isopera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0
let ischrome = !!window.chrome && !isopera
// let isexplorer = typeof document !== 'undefined' && !!document.documentMode && !isEdge
let isfirefox = typeof window.InstallTrigger !== 'undefined'
let issafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
let isiOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)
return {
isopera: isopera,
ischrome: ischrome,
isfirefox: isfirefox,
issafari: issafari,
isiOS: isiOS
}
}
const openNewTab = function () {
let tab = window.open(this.formData.redirect_url, '_blank')
tab.focus()
}
if (this.formData.category === 'form-redirect') {
let browser = getBrowserInfo()
if (browser.isiOS || browser.issafari) {
if (confirm('A page will open in new tab, please allow this page to open a new tab on your browser settings!')) {
openNewTab()
}
} else {
openNewTab()
}
}
}
},
mounted () {
Expand Down
6 changes: 5 additions & 1 deletion packages/ripple-nuxt-tide/modules/webform/mapping-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ module.exports = {
settings: {
shouldHideFormAfterSuccess: null
},
tag: 'rpl-fieldset'
tag: 'rpl-fieldset',
// TODO: Below category & redirect_url is used by VicPol only at this moment and the it's not in Tide.
// The implementation need to be reviewed.
category: drupalFormEntity.category,
redirect_url: drupalFormEntity.settings.confirmation_url
}

// If form confirmation type is inline, always hide the form after it has been successfully submitted.
Expand Down

0 comments on commit aea4394

Please sign in to comment.