diff --git a/ui/resources/views/currencies/show.blade.php b/ui/resources/views/currencies/show.blade.php
index 26c27dc..0a3d083 100644
--- a/ui/resources/views/currencies/show.blade.php
+++ b/ui/resources/views/currencies/show.blade.php
@@ -71,6 +71,18 @@
+
+
+
+
+
@@ -84,17 +96,27 @@
add_button: '#add_source',
add_modal: '#add_sources',
loading: '',
+ loaded: false,
sources: [],
setup: function() {
$(this.id).hide()
$(this.add_button).css('cursor', 'pointer').click((e) => {
this.add()
})
+ this.buildModal()
},
get: function(currency_id, data) {
- this.sources = data.sources
- this.populate(currency_id)
- socket.sendMessage('currency.values', {currency_id: '{{$currency_id}}'})
+ if (!this.loaded) {
+ this.sources = data.sources
+ this.populate(currency_id)
+ socket.sendMessage('currency.values', {currency_id: currency_id})
+ return
+ }
+ var url = '{{$urls->api}}/currency/' + currency_id + '/sources'
+ $.getJSON(url, (data) => {
+ this.sources = data.sources
+ this.populate(currency_id)
+ })
},
buildModal: function() {
$(this.add_modal).modal()
@@ -127,14 +149,15 @@
doAdd: function() {
let form = $(this.add_modal).find('form')
let info = {
- url: form.find("[name='url']").val()
+ url: form.find("[name='url']").val(),
+ frecuency: form.find("[name='frecuency']").val() + ' ' + form.find("[name='frec_name']").val()
}
- var url = '{{$urls->api}}/currency/' + this.data.id + '/sources/add'
+ var url = '{{$urls->api}}/currency/{{$currency_id}}/sources/add'
$(this.add_modal).modal('hide')
$(this.loading).modal('show')
$.post(url, JSON.stringify(info), (data) => {
if (data.sources[0].created) {
- this.get()
+ this.get('{{$currency_id}}')
}
}, 'json').then(() => {
$(this.loading).modal('hide')
@@ -163,6 +186,7 @@
add_modal: '#add_values',
loading: '',
values: [],
+ loaded: false,
setup: function() {
$(this.id).hide()
this.buildModal()
@@ -171,12 +195,20 @@
})
},
get: function(currency_id, data) {
- if (data.values.length > 0) {
+ if (!this.loaded) {
+ if (data.values.length > 0) {
+ this.values = data.values
+ this.populate(currency_id)
+ }
+ $(this.loading).modal('hide')
+ socket.conn.close()
+ return
+ }
+ var url = '{{$urls->api}}/currency/' + currency_id + '/values'
+ $.getJSON(url, (data) => {
this.values = data.values
this.populate(currency_id)
- }
- $(this.loading).modal('hide')
- socket.conn.close()
+ })
},
buildModal: function() {
this.getCurrencies()
@@ -229,12 +261,12 @@
value: form.find("[name='valor']").val(),
base_id: form.find('.ui.dropdown').dropdown('get value')
}
- var url = '{{$urls->api}}/currency/' + this.data.id + '/values/add'
+ var url = '{{$urls->api}}/currency/{{$currency_id}}/values/add'
$(this.add_modal).modal('hide')
$(this.loading).modal('show')
$.post(url, JSON.stringify(info), (data) => {
if (data.values[0].created) {
- this.get()
+ this.get('{{$currency_id}}')
}
}, 'json').then(() => {
$(this.loading).modal('hide')