Skip to content

Commit

Permalink
fix: refactor, add new props
Browse files Browse the repository at this point in the history
  • Loading branch information
yariksav committed Aug 1, 2020
1 parent 2f7631f commit de6d4ae
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 31 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ This module will help you to work with modal dialogs in your project

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fyariksav%2Fvuetify-dialog.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fyariksav%2Fvuetify-dialog?ref=badge_large)

## Documentation
=======
## Vuedl module documentation

This module uses vuedl for automatically work with dialogs and DOM
[See docs here](https://github.com/yariksav/vuedl#readme)

## Setup
Expand Down Expand Up @@ -260,8 +261,8 @@ Props:
{
...
actions: {
'false': 'No',
'true': 'Yes'
false: 'No',
true: 'Yes'
}
}
// result will be true, false, or undefigned
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuetify-dialog",
"version": "2.0.8",
"version": "2.0.9",
"description": "Dialog helper for vuetify.js",
"scripts": {
"build": "npm run build:umd & npm run build:es & npm run build:unpkg",
Expand Down Expand Up @@ -69,7 +69,7 @@
"vue-asyncable": "^0.2.0",
"vue-jest": "^3.0.4",
"vue-template-compiler": "^2.5.22",
"vuedl": "^0.3.9",
"vuedl": "^0.3.10",
"vuetify": "^2.3.4"
},
"jest": {
Expand Down
20 changes: 4 additions & 16 deletions src/components/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,10 @@ export default {
type: Boolean,
default: true
},
flat: {
type: Boolean,
default: false
},
border: {
type: String,
default: undefined
},
tile: {
type: Boolean,
default: false
},
dense: {
type: Boolean,
default: false
},
flat: Boolean,
border: String,
tile: Boolean,
dense: Boolean
}
}
</script>
11 changes: 9 additions & 2 deletions src/components/DialogCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
ref="actions"
:actions="actions"
v-bind="actionOptions"
:handle="handle"
:handler="handler || handle"
/>
<slot name="footer" />
</v-card>
</template>

Expand Down Expand Up @@ -50,7 +51,13 @@ export default {
flat: true
})
},
handle: Function
handle: Function, // todo: remove this parameter in next version
handler: Function
},
created () {
if (this.handle) {
console.warn('DEPRECATED: "handle" prop will be deprecated, please use "handler" instead')
}
},
methods: {
trigger (name) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<DialogCard
:title="title"
:actions="actions"
:handle="handleClick"
:handler="handlerClick"
:title-class="titleClass"
ref="card"
>
Expand Down Expand Up @@ -58,7 +58,7 @@ export default {
onEnter () {
this.$refs.card.$refs.actions.trigger(true)
},
handleClick (res, action) {
handlerClick (res, action) {
if (!action.key) {
this.$emit('submit', action.key)
}
Expand Down
13 changes: 11 additions & 2 deletions src/components/SnackbarLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
:color="getColor"
v-model="isActive"
class="application"
:text="false"
:top="top"
:left="left"
:right="right"
:bottom="bottom"
:multi-line="multiLine"
:vertical="vertical"
:elevation="elevation"
:text="flat"
:centered="centered"
:rounded="rounded"
:outlined="outlined"
:shaped="shaped"
@click="dismiss"
>
<dialog-child
Expand All @@ -37,7 +41,12 @@ export default {
position: String,
multiLine: Boolean,
vertical: Boolean,
elevation: Number
elevation: [Number, String],
flat: Boolean,
centered: Boolean,
rounded: [Boolean, String],
outlined: Boolean,
shaped: Boolean
},
data () {
const position = this.position || this.$options.propsData.position || ''
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/confirm.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ exports[`manager Check confirm with btns true|false 1`] = `
</div>
`;

exports[`manager Check confirm with handle functions 1`] = `
exports[`manager Check confirm with handler functions 1`] = `
<div
class="dialog-layout"
>
Expand Down
3 changes: 3 additions & 0 deletions test/__snapshots__/prompt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ exports[`manager Prompt confirm 2`] = `
</span>
</button>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -249,6 +250,7 @@ exports[`manager Prompt confirm 2`] = `
</span>
</button>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -394,6 +396,7 @@ exports[`manager Test default prompt 2`] = `
</span>
</button>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions test/confirm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ describe('manager', () => {
expect(document.body.innerHTML).toBe('')
})

test('Check confirm with handle functions', async () => {
test('Check confirm with handler functions', async () => {
const dlg = await manager.confirm({
text: 'test',
actions: {
false: 'No',
true: {
text: 'Yes',
class: 'action-true',
handle: () => {
handler: () => {
return new Promise((resolve) => {
setTimeout(() => resolve({ msg: 'foo' }), 5)
})
Expand Down
14 changes: 14 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ export interface DialogAction {
rounded? : boolean
disabled?: boolean
handle? (action: any): Promise<any>
handler? (action: any): Promise<any>
}

interface DialogActionable {
actions?: object | Array<string|DialogAction> | Array<DialogAction>
handle? (action: any): Promise<any>
handler? (action: any): Promise<any>
}

export interface DialogObject {
Expand All @@ -43,6 +45,14 @@ export interface DialogMessageOptions extends DialogActionable {
position?: string
timeout?: number
type?: string
outlined?: boolean
prominent?: boolean
dismissible?: boolean
flat?: boolean
centered?: boolean
border?: string
tile?: boolean
dense?: boolean
}

export interface DialogNotifyOptions extends DialogActionable {
Expand All @@ -54,6 +64,10 @@ export interface DialogNotifyOptions extends DialogActionable {
verticalOffset?: number
width?: number
zIndex?: number
flat?: boolean
rounded?: boolean
outlined?: boolean
shaped?: boolean
}

export interface DialogConfirmOptions extends DialogActionable {
Expand Down

0 comments on commit de6d4ae

Please sign in to comment.