Skip to content

Commit

Permalink
fix: include built JS
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Jul 3, 2022
1 parent f7ada06 commit 12492b8
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 24 deletions.
34 changes: 10 additions & 24 deletions check_run/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

# include js, css files in header of desk.html
# app_include_css = "/assets/check_run/css/check_run.css"
# app_include_js = "/assets/check_run/js/check_run.js"
app_include_js = [
"/assets/js/check_run.min.js"
]

# include js, css files in header of web template
# web_include_css = "/assets/check_run/css/check_run.css"
Expand All @@ -31,7 +33,10 @@
# page_js = {"page" : "public/js/file.js"}

# include js in doctype views
# doctype_js = {"doctype" : "public/js/doctype.js"}
doctype_js = {
'Employee': 'public/js/custom/employee_custom.js',
"Supplier": 'public/js/custom/supplier_custom.js',
}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
Expand All @@ -58,6 +63,7 @@

# before_install = "check_run.install.before_install"
# after_install = "check_run.install.after_install"
after_migrate = 'check_run.customize.load_customizations'

# Uninstallation
# ------------
Expand Down Expand Up @@ -127,7 +133,7 @@
# Testing
# -------

# before_tests = "check_run.install.before_tests"
# before_tests = "check_run.check_run.doctype.check_run.test_check_run.before_tests"

# Overriding Methods
# ------------------------------
Expand All @@ -150,27 +156,7 @@

# User Data Protection
# --------------------

user_data_fields = [
{
"doctype": "{doctype_1}",
"filter_by": "{filter_by}",
"redact_fields": ["{field_1}", "{field_2}"],
"partial": 1,
},
{
"doctype": "{doctype_2}",
"filter_by": "{filter_by}",
"partial": 1,
},
{
"doctype": "{doctype_3}",
"strict": False,
},
{
"doctype": "{doctype_4}"
}
]
#

# Authentication and authorization
# --------------------------------
Expand Down
6 changes: 6 additions & 0 deletions check_run/public/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"js/check_run.min.js": [
"public/js/check_run/check_run.js",
"public/js/custom/check_run_quick_entry.js"
]
}
171 changes: 171 additions & 0 deletions check_run/public/js/check_run/CheckRun.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<template>
<div>

<table class="table table-compact table-hover check-run-table" style="text-align: center; margin: 0;">
<thead>
<tr>
<th
style="text-align: left"
class="col col-sm-2"
id="check-run-party-filter"
>
<span class="party-onclick party-display">Party</span> <span class="filter-icon"><svg class="icon icon-sm" style="" @click="toggleShowPartyFilter()">
<use class="" href="#icon-filter"></use>
</svg></span>
<div class="party-filter" v-if="state.show_party_filter">
<input type="text" class="form-control" v-model="state.party_filter" />
</div>
</th>
<th class="col col-sm-2">Document</th>
<th class="col col-sm-2" style="white-space: nowrap; width: 12.49%">
Document Date
<span @click="sortTransactions('posting_date')" class="check-run-sort-indicator" id="check-run-doc-date-sort">&#11021;</span>
</th>
<th class="col col-sm-2" tyle="white-space: nowrap; width: 12.49%">Mode of Payment
<span @click="sortTransactions('mode_of_payment')" class="check-run-sort-indicator" id="check-run-mop-sort">&#11021;</span>
</th>
<th class="col col-sm-2">
Outstanding Amount
<span @click="sortTransactions('amount')" class="check-run-sort-indicator" id="check-run-outstanding-sort">&#11021;</span>
</th>
<th class="col col-sm-1">
Due Date
<span @click="sortTransactions('due_date')" class="check-run-sort-indicator" id="check-run-due-date-sort">&#11021;</span>
</th>
<th v-if="state.docstatus < 1" style="min-width:200px; text-align: left">
<input type="checkbox" autocomplete="off" class="input-with-feedback reconciliation" data-fieldtype="Check"
id="select-all" v-model="selectAll"> Select All</input>
</th>
<th v-else class="col col-sm-2"> Check Number | Reference </th>
</tr>
</thead>
<tbody>

<template v-for="(item, i) in transactions">
<tr
v-if="partyIsInFilter(transactions[i].party)"
class="checkrun-row-container"
tabindex="1"
>
<td style="text-align: left">{{ transactions[i].party }}</td>
<td>
<a
:href="transactionUrl(i)"
target="_blank"
>
{{ transactions[i].ref_number || transactions[i].name}}
</a>
</td>
<td> {{ transactions[i].posting_date }} </td>


<td
class="mop-onclick"
:data-mop-index="i"
>
<select
v-if="state.docstatus < 1"
class="mop-input form-control"
:data-mop="transactions[i].mode_of_payment"
v-model="transactions[i].mode_of_payment"
@change="markDirty()"
>
<option></option>
<template v-for="(mop, j) in modes_of_payment">
<option :value="modes_of_payment[j].name">{{modes_of_payment[j].name}}</option>
</template>
</select>
<span v-else>{{ transactions[i].mode_of_payment }}</span>
</td>


<td>{{ format_currency(transactions[i].amount, "USD", 2) }}</td>
<td>{{ moment(transactions[i].due_date).format("MM/DD/YY") }}</td>
<td v-if="state.docstatus < 1" style="text-align: left">
<input
type="checkbox"
class="input-with-feedback checkrun-check-box"
data-fieldtype="Check"
@change="markDirty()"
:data-checkbox-index="i"
v-model="transactions[i].pay"
:id="transactions[i].id" />Pay
</td>
<td v-else>
<a :href="paymentEntryUrl(i)" target="_blank">
{{ transactions[i].check_number }}</a></td>
</tr>
</template>

</tbody>
</table>


</div>
</template>
<script>
export default {
name: 'CheckRun',
props: ['transactions', 'modes_of_payment', 'docstatus', 'state'],
data(){
return {
selectAll: false,
sort_order: {
posting_date: 1,
mode_of_payment: 1,
amount: 1,
due_date: 1
}
}
},
watch: {
selectAll: (val, oldVal) => {
for(let idx = 0;idx < cur_frm.check_run_state.transactions.length; idx++){
cur_frm.check_run_state.transactions[idx].pay = val;
}
cur_frm.dirty();
}
},
methods: {
transactionUrl: transactionId => {
if(!this.transactions) {
return "";
}
return encodeURI(frappe.urllib.get_base_url() + "/app/" + this.transactions[transactionId].doctype.toLowerCase().replace(" ", "-") + "/" + thiis.transactions[transactionId].name );
},
paymentEntryUrl: transactionId => {
if(!this.transactions) {
return "";
}
return encodeURI(frappe.urllib.get_base_url() + "/app/payment-entry/" + this.transactions[i].payment_entry );
},
sortTransactions(key) {
this.transactions.sort((a, b) => (a[key] > b[key] ? this.sort_order[key] : this.sort_order[key] * -1));
this.sort_order[key] *= -1;
},
partyIsInFilter(party) {
return cur_frm.check_run_state.party_filter.length < 1 || party.toLowerCase().includes(cur_frm.check_run_state.party_filter.toLowerCase());
},
toggleShowPartyFilter() {
cur_frm.check_run_state.party_filter = "";
cur_frm.check_run_state.show_party_filter = !cur_frm.check_run_state.show_party_filter;
},
markDirty() {
cur_frm.dirty();
}
},
beforeMount() {
this.moment = moment;
this.format_currency = format_currency;
}
}
</script>
<style scoped>
.party-filter {
margin-top: 5px;
}
.table thead th {
vertical-align: top;
}
</style>
38 changes: 38 additions & 0 deletions check_run/public/js/check_run/check_run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import CheckRun from './CheckRun.vue'

frappe.provide('check_run')

check_run.mount_table = (frm, wrapper) => {
if (frm.$check_run instanceof Vue) { return }
window.Vue.component('CheckRun', CheckRun)
const state = Vue.observable({
transactions: frm.transactions,
party_filter: "",
docstatus: frm.doc.docstatus,
modes_of_payment: frm.modes_of_payment,
show_party_filter: false
})
if (frm.$check_run instanceof Vue) {
frm.check_run_state.docstatus = frm.doc.docstatus;
frm.check_run_state.transactions = frm.transactions;
frm.check_run_state.modes_of_payment = state.modes_of_payment;
frm.check_run_state.state = state;
frm.$check_run_vue.$forceUpdate();
return;
}

frm.check_run_state = state;
frm.$check_run = new window.Vue({
el: wrapper.get(0),
render: h => h(
CheckRun,
{ props: {
transactions: state.transactions, //list of transtactions
modes_of_payment: state.modes_of_payment, // populate modes_of_payment select. doesn't get updated
docstatus: state.docstatus, // used to conditionally render column inputs based on submission status. doesn't get updated
state: state
}
}),
})
}
// })

0 comments on commit 12492b8

Please sign in to comment.