Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 21 additions & 66 deletions resources/assets/js/components/AkauntingDropzoneFileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {
type: Object,
default: () => ({})
},
value: [String, Object, Array],
value: [String, Object, Array, File],
url: {
type: String,
default: 'http:'
Expand Down Expand Up @@ -99,88 +99,43 @@ export default {
thumbnailHeight: null,
previewsContainer: preview,
previewTemplate: preview.innerHTML,
autoProcessQueue: false,
init: function () {
this.on("addedfile", function (file) {
self.files.push(file);

if (self.options.maxFiles == 1) {
self.$emit('change', file);
} else {
self.$emit('change', this.files);
self.$emit('change', self.files);
}
}),
this.on("removedfile", function (file) {
let index = self.files.findIndex(f => f.upload.uuid === file.upload.uuid);

if (index !== -1) {
self.files.splice(index, 1);
}

self.$emit('change', self.files);

if(self.isPreviewSingle == false)
this.enable()
}),
this.on("maxfilesexceeded", function(file) {
this.removeAllFiles('notCancel');
this.addFile(file);
});
}),
this.on("maxfilesreached", function(file) {
if(self.isPreviewSingle == false)
this.disable()
})
}
};

this.dropzone = new Dropzone(this.$el, finalOptions);

preview.innerHTML = '';

let evtList = [
'drop',
'dragstart',
'dragend',
'dragenter',
'dragover',
'addedfile',
'removedfile',
'thumbnail',
'error',
'processing',
'uploadprogress',
'sending',
'success',
'complete',
'canceled',
'maxfilesreached',
'maxfilesexceeded',
'processingmultiple',
'sendingmultiple',
'successmultiple',
'completemultiple',
'canceledmultiple',
'totaluploadprogress',
'reset',
'queuecomplete',
];

evtList.forEach(evt => {
this.dropzone.on(evt, (file) => {
this.$emit(evt, file);
/*
if (evt === 'addedfile') {
if (self.multiple) {
this.files.push(file);

this.$emit('change', this.files);
} else {
this.file = file;
this.$emit('change', file);
}
}
*/

if (evt === 'removedfile') {
//if (self.multiple) {
let index = this.files.findIndex(f => f.upload.uuid === file.upload.uuid);

if (index !== -1) {
this.files.splice(index, 1);
}

this.$emit('change', this.files);
//} else {
// this.file = '';

// this.$emit('change', '');
//}
}
})
}, this);
preview.innerHTML = ''
}
},

Expand Down
149 changes: 79 additions & 70 deletions resources/assets/js/components/AkauntingHtmlEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,103 +11,112 @@
<button type="button" class="ql-list" value="bullet"></button>
</div>
</div>

<div :id="editorId" :name="name" class="" ref="editor">
</div>
</div>
</template>

<script>
export default {
import Quill from 'quill';

export default {
name: 'akaunting-html-editor',

props: {
value: {
type: String,
default: ''
},
name: String
name: String,
value: {
type: String,
default: ''
},
theme: {
type: String,
default: 'snow'
},
},

data () {
return {
editor: null,
content: null,
lastHtmlValue: '',
editorId: null,
toolbarId: null
}
return {
editor: null,
content: null,
lastHtmlValue: '',
editorId: null,
toolbarId: null
}
},

methods: {
initialize (Quill) {
this.editor = new Quill(`#${this.editorId}`, {
theme: 'snow',
modules: {
toolbar: `#${this.toolbarId}`
}
})

if (this.value.length > 0) {
this.editor.pasteHTML(this.value)
}
initialize (Quill) {
let theme = this.theme;

let editorRef = this.$refs.editor;
let node = editorRef.children[0];
this.editor = new Quill(`#${this.editorId}`, {
theme: theme,
modules: {
toolbar: `#${this.toolbarId}`
}
});

this.editor.on('text-change', () => {
let html = node.innerHTML;
if (this.value.length > 0) {
this.editor.pasteHTML(this.value)
}

if (html === '<p><br></p>') {
html = '';
}
let editorRef = this.$refs.editor;
let node = editorRef.children[0];

this.content = html;
this.editor.on('text-change', () => {
let html = node.innerHTML;

this.$emit('input', this.content);
})
},
if (html === '<p><br></p>') {
html = '';
}

pasteHTML () {
if (!this.editor) {
return
}
this.content = html;

this.editor.pasteHTML(this.value);
},
this.$emit('input', this.content);
});
},

randomString() {
let text = "";
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
pasteHTML () {
if (!this.editor) {
return;
}

for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
this.editor.pasteHTML(this.value);
},

return text;
}
},
randomString() {
let text = "";
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

async mounted () {
this.content = this.value;
for (let i = 0; i < 5; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}

let Quill = await import('quill');
return text;
},
},

Quill = Quill.default || Quill;
async mounted () {
this.content = this.value;

this.editorId = this.randomString();
this.toolbarId = this.randomString();
this.editorId = this.randomString();
this.toolbarId = this.randomString();

this.$nextTick(() => {
this.initialize(Quill)
});
this.$nextTick(() => {
this.initialize(Quill)
});
},

watch: {
value (newVal) {
if (newVal !== this.content) {
this.pasteHTML(newVal);
}
},

content (newVal) {
this.$emit('input', newVal);
}
}
}
value (newVal) {
if (newVal !== this.content) {
this.pasteHTML(newVal);
}
},

content (newVal) {
this.$emit('input', newVal);
},
},
}
</script>
14 changes: 7 additions & 7 deletions resources/views/components/documents/form/totals.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<table class="table" id="totals">
<colgroup>
<col style="width: 50%;">
<col style="width: 35%;">
<col style="width: 30%;">
<col style="width: 25%;">
<col style="width: 40px;">
</colgroup>
<tbody id="invoice-total-rows" class="table-padding-05">
@stack('sub_total_td_start')
<tr id="tr-subtotal">
<td class="border-bottom-0 pb-0"></td>
<td class="text-right border-right-0 border-bottom-0 align-middle pb-0">
<td class="text-right border-right-0 border-bottom-0 align-middle pb-0 pr-0">
<strong>{{ trans('invoices.sub_total') }}</strong>
</td>
<td class="text-right border-bottom-0 long-texts pb-0 pr-3">
Expand All @@ -28,7 +28,7 @@
@stack('item_discount_td_start')
<tr id="tr-line-discount" v-if="totals.item_discount">
<td class="border-top-0 pt-0 pb-0"></td>
<td class="text-right border-top-0 border-right-0 border-bottom-0 align-middle pt-0 pb-0">
<td class="text-right border-top-0 border-right-0 border-bottom-0 align-middle pt-0 pb-0 pr-0">
<strong>{{ trans('invoices.item_discount') }}</strong>
</td>
<td class="text-right border-top-0 border-bottom-0 long-texts pt-0 pb-0 pr-3">
Expand All @@ -45,7 +45,7 @@
@stack('add_discount_td_start')
<tr id="tr-discount">
<td class="border-top-0 pt-0 pb-0"></td>
<td class="text-right border-top-0 border-right-0 border-bottom-0 align-middle pt-0 pb-0">
<td class="text-right border-top-0 border-right-0 border-bottom-0 align-middle pt-0 pb-0 pr-0">
<el-popover
popper-class="p-0 h-0"
placement="bottom"
Expand Down Expand Up @@ -101,7 +101,7 @@
<tr v-for="(tax, tax_index) in totals.taxes"
:index="tax_index">
<td class="border-top-0 pt-0 pb-0"></td>
<td class="text-right border-top-0 border-right-0 border-bottom-0 align-middle pt-0 pb-0">
<td class="text-right border-top-0 border-right-0 border-bottom-0 align-middle pt-0 pb-0 pr-0">
<strong v-html="tax.name"></strong>
</td>
<td class="text-right border-top-0 border-bottom-0 long-texts pb-0 pr-3">
Expand All @@ -116,7 +116,7 @@
@stack('grand_total_td_start')
<tr id="tr-total">
<td class="border-top-0 pt-0 pb-0"></td>
<td class="text-right border-top-0 border-right-0 align-middle pt-0 pb-0">
<td class="text-right border-top-0 border-right-0 align-middle pt-0 pb-0 pr-0">
<strong class="document-total-span">{{ trans('invoices.total') }}</strong>
{{ Form::selectGroup('currency_code', '', 'exchange-alt', $currencies, setting('default.currency'), ['required' => 'required', 'model' => 'form.currency_code', 'change' => 'onChangeCurrency'], 'document-total-currency') }}
</td>
Expand All @@ -132,7 +132,7 @@
@stack('currency_conversion_td_start')
<tr id="tr-currency-conversion" class="d-none" :class="[{'d-table-row': (('{{ setting('default.currency') }}' != form.currency_code) && totals.total)}]">
<td class="border-top-0 pb-0"></td>
<td class="text-right border-top-0 border-right-0 align-middle pb-0 pr-3" colspan="2">
<td class="text-right border-top-0 border-right-0 align-middle pb-0 pr-3 pr-0" colspan="2">
<akaunting-currency-conversion
currency-conversion-text="{{ trans('currencies.conversion') }}"
:price="(totals.total / form.currency_rate).toFixed(2)"
Expand Down
Loading