Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #52 from wilcorrea-forks/master
Browse files Browse the repository at this point in the history
[#50/review] Rename design to agnostic
  • Loading branch information
wilcorrea authored May 14, 2019
2 parents a4f773e + ec5401b commit 0f26d68
Show file tree
Hide file tree
Showing 73 changed files with 336 additions and 220 deletions.
30 changes: 11 additions & 19 deletions src/app/Prototype/Base.js → src/app/Agnostic/Base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-underscore-dangle */
import components from 'src/config/app/components'
import { apply, clone } from 'src/app/Util'
import { scopes } from 'src/app/Agnostic/enum'
import { lang } from 'src/app/Util/Lang'

/**
Expand All @@ -17,27 +18,25 @@ export default class Base {
/**
* @type {Array}
*/
static searchHidden = ['ativo']

/**
* @type {string}
*/
primaryKey = 'id'
static mixins = []

/**
* @type {string}
* @type {Object}
*/
displayKey = 'id'
static buttons = {
color: 'white',
textColor: 'grey-10'
}

/**
* @type {string}
*/
titleForm = ''
primaryKey = 'id'

/**
* @type {string}
*/
titleTable = ''
displayKey = 'id'

/**
* @type {Service}
Expand All @@ -47,7 +46,7 @@ export default class Base {
/**
* @type {String[]}
*/
scopes = ['index', 'create', 'read', 'update']
scopes = scopes()

/**
* @type {Object}
Expand All @@ -57,9 +56,7 @@ export default class Base {
/**
* @type {Object}
*/
form = {
action: 'save'
}
form = {}

/**
* @type {Object}
Expand All @@ -71,11 +68,6 @@ export default class Base {
*/
is = 'input'

/**
* @type {Array}
*/
static mixins = []

/**
* @type {boolean}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Trigger from './Hook'
import Button from './Button'
import Trigger from 'src/app/Agnostic/Components/Contracts/Hook'
import Button from 'src/app/Agnostic/Components/Contracts/Button'

/**
* @typedef {Basic}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Basic from './Basic'
import Basic from 'src/app/Agnostic/Components/Contracts/Basic'

/**
* @typedef {FormDynamic}
Expand Down Expand Up @@ -44,10 +44,6 @@ export default {
type: String,
default: () => ''
},
service: {
type: [Object, Function],
default: () => ({})
},
fields: {
type: Function,
default: () => ({})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import FormComponents from './Form/FormComponents'
import FormError from './Form/FormError'
import FormFetch from './Form/FormFetch'
import FormField from './Form/FormField'
import FormRecord from './Form/FormRecord'
import FormValidation from './Form/FormValidation'
import FormComponents from 'src/app/Agnostic/Components/Contracts/Form/FormComponents'
import FormError from 'src/app/Agnostic/Components/Contracts/Form/FormError'
import FormFetch from 'src/app/Agnostic/Components/Contracts/Form/FormFetch'
import FormField from 'src/app/Agnostic/Components/Contracts/Form/FormField'
import FormRecord from 'src/app/Agnostic/Components/Contracts/Form/FormRecord'
import FormValidation from 'src/app/Agnostic/Components/Contracts/Form/FormValidation'

/**
* @typedef {Form}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FormComponent from 'src/app/Prototype/Contracts/Form/FormComponent'
import FormComponent from 'src/app/Agnostic/Components/Contracts/Form/FormComponent'

/**
* @mixin {FieldComponents}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@ export default {
/**
*/
methods: {
/**
*/
loadingShow () {
this.$q.loading.show({ delay: 100 })
},
/**
*/
loadingHide () {
this.$q.loading.hide()
},
/**
* @param {Number|String} id
* @returns {Promise}
*/
fetchRecord (id) {
this.$q.loading.show({ delay: 100 })
return this.$service
.read(id)
this.loadingShow()

this.triggerHook('request:record', { id })
.then(this.successFetchRecord)
.catch(this.errorFetchRecord)
.finally(() => this.$q.loading.hide())
},
/**
* @param {Object} record
*/
successFetchRecord (record) {
this.loadingHide()

this.fetching = true
this.$payload = this.$util.clone(record)
const recordName = this.$options.recordName || 'record'
Expand All @@ -37,7 +48,14 @@ export default {
/**
*/
errorFetchRecord (/* error */) {
this.loadingHide()

// this.$error.report(error)
}
},
/**
*/
mounted () {
this.fetchRecord(this.$route.params[this.primaryKey])
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseValidations } from 'src/app/Prototype/Contracts/Helper/validation'
import { parseValidations } from 'src/app/Agnostic/Components/Contracts/Helper/validation'

/**
* @mixin {FormValidation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default {
methods: {
/**
* @param {string} hook
* @param {Object} context
*/
triggerHook (hook) {
triggerHook (hook, context) {
const hooks = this.hooks()

if (!hooks) {
Expand All @@ -21,7 +22,7 @@ export default {
if (typeof action !== 'function') {
return
}
action.call(this)
return action.call(this, context)
}
},
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Basic from './Basic'
import Basic from 'src/app/Agnostic/Components/Contracts/Basic'

/**
* @typedef {Static}
Expand All @@ -19,7 +19,6 @@ export default {
'settings',
'primaryKey',
'displayKey',
'service',
'fields',
'actions',
'hooks'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import TableColumns from './Table/TableColumns'
import TableFetch from './Table/TableFetch'
import TableColumns from 'src/app/Agnostic/Components/Contracts/Table/TableColumns'
import TableFetch from 'src/app/Agnostic/Components/Contracts/Table/TableFetch'

/**
* @typedef {Table}
Expand Down Expand Up @@ -30,7 +30,7 @@ export default {
descending: false,
page: this.$route.query.page ? Number(this.$route.query.page) : 1,
pagesNumber: 1,
rowsPerPage: this.service ? this.service.size : this.size
rowsPerPage: this.size
},
selected: [],
loading: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ export default {
*/
methods: {
/**
* @param {Object} options
*/
fetchRecords (options = {}) {
loadingShow () {
this.loading = true
this.$q.loading.show({ delay: 100 })

const hide = () => {
this.$q.loading.hide()
this.loading = false
}
},
/**
*/
loadingHide () {
this.$q.loading.hide()
this.loading = false
},
/**
* @param {Object} options
*/
fetchRecords (options = {}) {
this.loadingShow()

if (options === undefined || Object.keys(options).length === 0) {
options = {
Expand All @@ -42,20 +48,16 @@ export default {
filter: this.filter
}

try {
return this.service
.search(parameters, this.filters)
.then(this.successFetchRecords)
.catch(this.errorFetchRecords)
.finally(hide)
} catch (error) {
hide()
}
this.triggerHook('request:records', { parameters, filters: this.filters })
.then(this.successFetchRecords)
.catch(this.errorFetchRecords)
},
/**
* @param {Object} response
*/
successFetchRecords (response) {
this.loadingHide()

this.data = response.rows
this.pagination.rowsPerPage = response.rowsPerPage
this.pagination.pagesNumber = response.pagesNumber
Expand All @@ -72,6 +74,8 @@ export default {
* // @param {Object} error
*/
errorFetchRecords (/* error */) {
this.loadingHide()

this.data = []
},
/**
Expand Down Expand Up @@ -107,5 +111,10 @@ export default {
'$route.query.search' () {
this.fetchRecords()
}
},
/**
*/
mounted () {
this.fetchRecords()
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Dynamic from '../Contracts/Dynamic'
import Form from '../Contracts/Form'
import PrototypeButtons from 'src/app/Prototype/Components/PrototypeButtons'
import PrototypeFormComponents from 'src/app/Prototype/Components/Form/PrototypeComponents'
import PrototypeBody from 'src/app/Prototype/Components/Form/PrototypeBody'
import Dynamic from './Contracts/Dynamic'
import Form from './Contracts/Form'
import PrototypeButtons from 'src/app/Agnostic/Components/PrototypeButtons'
import PrototypeFormComponents from 'src/app/Agnostic/Components/Form/PrototypeComponents'
import PrototypeBody from 'src/app/Agnostic/Components/Form/PrototypeBody'
import { POSITIONS } from 'src/app/Agnostic/enum'

/**
* @typedef PrototypeForm
Expand Down Expand Up @@ -37,7 +38,7 @@ export default {
const data = { class: 'app-form-wrapper' }
const children = [
this.renderFormBody(h),
this.renderPrototypeButtons(h, 'form-footer', { record: this.record })
this.renderPrototypeButtons(h, POSITIONS.POSITION_FORM_FOOTER, { record: this.record })
]

return h('div', data, children)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Dynamic from '../Contracts/Dynamic'
import Table from '../Contracts/Table'
import PrototypeSlots from 'src/app/Prototype/Components/Table/PrototypeSlots'
import Dynamic from './Contracts/Dynamic'
import Table from './Contracts/Table'
import PrototypeSlots from 'src/app/Agnostic/Components/Table/PrototypeSlots'

import PrototypeButtons from './PrototypeButtons'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { renderTableColumnsSelector, renderTableSearch } from './PrototypeSlotTop'
import { POSITIONS } from 'src/app/Agnostic/enum'

/**
* @typedef {PrototypeTop}
Expand Down Expand Up @@ -33,7 +34,7 @@ export default {
return [
this.renderTableColumnsSelector(h),
h('q-space'),
this.renderPrototypeButtonsCompact(h, 'table-top', { records: this.selected }),
this.renderPrototypeButtonsCompact(h, POSITIONS.POSITION_TABLE_TOP, { records: this.selected }),
h('q-space'),
this.renderTableSearch(h)
]
Expand All @@ -59,7 +60,7 @@ export default {
}
const children = [
props.row[this.primaryKey],
this.renderPrototypeButtonsCompact(h, 'table-cell', { record: props.row })
this.renderPrototypeButtonsCompact(h, POSITIONS.POSITION_TABLE_CELL, { record: props.row })
]

return h('q-td', data, children)
Expand Down
Loading

0 comments on commit 0f26d68

Please sign in to comment.