-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Akaunting money vue component added for all create/ edit formGroup
- Loading branch information
1 parent
29782c1
commit 6695c76
Showing
9 changed files
with
163 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<template> | ||
<div class="form-group" | ||
:class="[{'has-error': error}, {'required': required}, {'readonly': readonly}, {'disabled': disabled}, col]"> | ||
<label v-if="title" :for="name" class="form-control-label">{{ title }}</label> | ||
|
||
<div class="input-group input-group-merge" :class="group_class"> | ||
<div v-if="icon" class="input-group-prepend"> | ||
<span class="input-group-text"> | ||
<i class="fa fa-" :class="icon"></i> | ||
</span> | ||
</div> | ||
|
||
<money :name="name" :placeholder="placeholder" v-model="model" v-bind="money" class="form-control"></money> | ||
</div> | ||
|
||
<div class="invalid-feedback d-block" v-if="error" v-html="error"></div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import {Money} from 'v-money'; | ||
export default { | ||
name: "akaunting-money", | ||
components: { | ||
Money | ||
}, | ||
props: { | ||
title: { | ||
type: String, | ||
default: '', | ||
description: "Selectbox label text" | ||
}, | ||
placeholder: { | ||
type: String, | ||
default: '', | ||
description: "Selectbox input placeholder text" | ||
}, | ||
name: { | ||
type: String, | ||
default: null, | ||
description: "Selectbox attribute name" | ||
}, | ||
value: { | ||
type: String, | ||
default: null, | ||
description: "Selectbox selected value" | ||
}, | ||
icon: { | ||
type: String, | ||
description: "Prepend icon (left)" | ||
}, | ||
group_class: { | ||
type: String, | ||
default: null, | ||
description: "Selectbox disabled status" | ||
}, | ||
col: { | ||
type: String, | ||
default: null, | ||
description: "Selectbox disabled status" | ||
}, | ||
error: { | ||
type: String, | ||
default: null, | ||
description: "Selectbox disabled status" | ||
}, | ||
readonly: { | ||
type: Boolean, | ||
default: false, | ||
description: "Selectbox disabled status" | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false, | ||
description: "Selectbox disabled status" | ||
}, | ||
currency: { | ||
type: Object, | ||
default: function () { | ||
return { | ||
decimal_mark: '.', | ||
thousands_separator: ',', | ||
symbol_first: 1, | ||
symbol: '$', | ||
precision: '2', | ||
}; | ||
}, | ||
description: "Default currency" | ||
}, | ||
masked: { | ||
type: Boolean, | ||
default: false, | ||
description: "Money result value" | ||
}, | ||
}, | ||
data() { | ||
return { | ||
model: this.value, | ||
money: { | ||
decimal: this.currency.decimal_mark, | ||
thousands: this.currency.thousands_separator, | ||
prefix: (this.currency.symbol_first) ? this.currency.symbol : '', | ||
suffix: (!this.currency.symbol_first) ? this.currency.symbol : '', | ||
precision: this.currency.precision, | ||
masked: this.masked | ||
} | ||
} | ||
}, | ||
mounted() { | ||
this.$emit('interface', this.model); | ||
}, | ||
methods: { | ||
change() { | ||
this.$emit('change', this.model); | ||
this.$emit('interface', this.model); | ||
}, | ||
}, | ||
watch: { | ||
model: function (options) { | ||
this.$emit('interface', this.model); | ||
} | ||
}, | ||
} | ||
</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
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
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
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 |
---|---|---|
@@ -1,38 +1,35 @@ | ||
@stack($name . '_input_start') | ||
|
||
<div | ||
class="form-group {{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['readonly']) ? ' readonly' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}" | ||
:class="[{'has-error': {{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }} }]"> | ||
@if (!empty($text)) | ||
{!! Form::label($name, $text, ['class' => 'form-control-label'])!!} | ||
<akaunting-money :col="'{{ $col }}'" | ||
:required="{{ isset($attributes['required']) ? true : false }}" | ||
|
||
@if (isset($attributes['readonly'])) | ||
:readonly="'{{ $attributes['readonly'] }}'" | ||
@endif | ||
|
||
@if (isset($attributes['disabled'])) | ||
:disabled="'{{ $attributes['disabled'] }}'" | ||
@endif | ||
|
||
<div class="input-group input-group-merge {{ $group_class }}"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text"> | ||
<i class="fa fa-{{ $icon }}"></i> | ||
</span> | ||
</div> | ||
@php | ||
if ($attributes['currency']) { | ||
$value = number_format($value, $attributes['currency']->precision, $attributes['currency']->decimal_mark, $attributes['currency']->thousands_separator); | ||
} else { | ||
$value = number_format($value, 2); | ||
} | ||
@endphp | ||
{!! Form::text($name, $value, array_merge([ | ||
'class' => 'form-control', | ||
'data-name' => $name, | ||
'data-value' => $value, | ||
'v-model.lazy' => !empty($attributes['v-model']) ? $attributes['v-model'] : (!empty($attributes['data-field']) ? 'form.' . $attributes['data-field'] . '.'. $name : 'form.' . $name), | ||
'v-money' => 'money', | ||
], $attributes)) !!} | ||
</div> | ||
@if (isset($attributes['masked'])) | ||
:masked="'{{ $attributes['masked'] }}'" | ||
@endif | ||
|
||
:error="{{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }}" | ||
:name="'{{ $name }}'" | ||
:title="'{{ $text }}'" | ||
:group_class="'{{ $group_class }}'" | ||
:icon="'{{ $icon }}'" | ||
:currency="{{ json_encode($attributes['currency']) }}" | ||
:value="{{ $value }}" | ||
|
||
<div class="invalid-feedback d-block" | ||
v-if="{{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.has("' . $name . '")' }}" | ||
v-html="{{ isset($attributes['v-error-message']) ? $attributes['v-error-message'] : 'form.errors.get("' . $name . '")' }}"> | ||
</div> | ||
</div> | ||
@if (!empty($attributes['v-model'])) | ||
@interface="{{ $attributes['v-model'] . ' = $event' }}" | ||
@elseif (!empty($attributes['data-field'])) | ||
@interface="{{ 'form.' . $attributes['data-field'] . '.' . $name . ' = $event' }}" | ||
@else | ||
@interface="form.{{ $name }} = $event" | ||
@endif | ||
></akaunting-money> | ||
|
||
@stack($name . '_input_end') |
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
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
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
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