-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-- Fixed issue where you can't edit a listener field -- Added Date Broadcaster field -- Added Date Listener field -- Added 'calculate' buttons to all visible Listener Fields -- Added ability to turn of calculation on update forms. -- Updated README.md
- Loading branch information
1 parent
a4435eb
commit d3083b0
Showing
19 changed files
with
638 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<template> | ||
<panel-item :field="field"> | ||
<template slot="value"> | ||
<p v-if="field.value" class="text-90">{{ formattedDate }}</p> | ||
<p v-else>—</p> | ||
</template> | ||
</panel-item> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['resource', 'resourceName', 'resourceId', 'field'], | ||
computed: { | ||
formattedDate() { | ||
if (this.field.format) { | ||
return moment(this.field.value).format(this.field.format) | ||
} | ||
return this.field.value | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<template> | ||
<panel-item :field="field"> | ||
<template slot="value"> | ||
<p v-if="field.value" class="text-90">{{ formattedDate }}</p> | ||
<p v-else>—</p> | ||
</template> | ||
</panel-item> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['resource', 'resourceName', 'resourceId', 'field'], | ||
computed: { | ||
formattedDate() { | ||
if (this.field.format) { | ||
return moment(this.field.value).format(this.field.format) | ||
} | ||
return this.field.value | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<default-field :field="field" :errors="errors" :show-help-text="showHelpText"> | ||
<template slot="field"> | ||
<div class="flex items-center"> | ||
<date-time-picker | ||
class="w-full form-control form-input form-input-bordered" | ||
ref="dateTimePicker" | ||
:dusk="field.attribute" | ||
:name="field.name" | ||
:value="value" | ||
:dateFormat="pickerFormat" | ||
:alt-format="pickerDisplayFormat" | ||
:placeholder="placeholder" | ||
:enable-time="false" | ||
:enable-seconds="false" | ||
:first-day-of-week="firstDayOfWeek" | ||
:class="errorClasses" | ||
@change="setFieldAndMessage" | ||
:disabled="isReadonly" | ||
/> | ||
|
||
<a | ||
v-if="field.nullable" | ||
@click.prevent="$refs.dateTimePicker.clear()" | ||
href="#" | ||
:title="__('Clear value')" | ||
tabindex="-1" | ||
class="p-1 px-2 cursor-pointer leading-none focus:outline-none" | ||
:class="{ | ||
'text-50': !value.length, | ||
'text-black hover:text-danger': value.length, | ||
}" | ||
> | ||
<icon type="x-circle" width="22" height="22" viewBox="0 0 22 22" /> | ||
</a> | ||
</div> | ||
</template> | ||
</default-field> | ||
</template> | ||
|
||
<script> | ||
import { | ||
FormField, | ||
HandlesValidationErrors, | ||
InteractsWithDates, | ||
} from 'laravel-nova' | ||
export default { | ||
mixins: [HandlesValidationErrors, FormField, InteractsWithDates], | ||
props: ['resourceName', 'resourceId', 'field'], | ||
methods: { | ||
setFieldAndMessage(value) { | ||
let parsedValue = value; | ||
let attribute = this.field.attribute | ||
if (Array.isArray(this.field.broadcastTo)) { | ||
this.field.broadcastTo.forEach(function (broadcastChannel) { | ||
Nova.$emit(broadcastChannel, { | ||
'field_name': attribute, | ||
'value': parsedValue | ||
}) | ||
}); | ||
} else { | ||
Nova.$emit(this.field.broadcastTo, { | ||
'field_name': attribute, | ||
'value': parsedValue | ||
}) | ||
} | ||
this.value = parsedValue; | ||
}, | ||
/** | ||
* Update the field's internal value when it's value changes | ||
*/ | ||
handleChange(value) { | ||
this.value = value; | ||
}, | ||
}, | ||
computed: { | ||
firstDayOfWeek() { | ||
return this.field.firstDayOfWeek || 0 | ||
}, | ||
placeholder() { | ||
return this.field.placeholder || moment().format(this.format) | ||
}, | ||
format() { | ||
return this.field.format || 'YYYY-MM-DD' | ||
}, | ||
pickerFormat() { | ||
return this.field.pickerFormat || 'Y-m-d' | ||
}, | ||
pickerDisplayFormat() { | ||
return this.field.pickerDisplayFormat || 'Y-m-d' | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.