mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-10 15:26:10 -06:00
Merge pull request #800 from openclassify/vedat
remove crud function && create new function
This commit is contained in:
commit
907d31fcac
@ -1,29 +1,17 @@
|
|||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
async: false,
|
|
||||||
data: params,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var level = 0;
|
var level = 0;
|
||||||
var selected;
|
var selected;
|
||||||
var all_categories = {};
|
var all_categories = {};
|
||||||
var promiseForCategory = new Promise(function (resolve) {
|
var promiseForCategory = new Promise(function (resolve) {
|
||||||
if (categories.length != 0) {
|
if (categories.length != 0) {
|
||||||
$.each(categories, function (index, value) {
|
$.each(categories, function (index, value) {
|
||||||
crud({'level': level, "cat": categories['cat' + level]}, '/class/ajaxCategory', 'POST', function (callback) {
|
crudAjax({'level': level, "cat": categories['cat' + level]}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
// console.log('cat' + (level + 1), categories['cat' + level], callback)
|
// console.log('cat' + (level + 1), categories['cat' + level], callback)
|
||||||
all_categories['cat' + (level + 1)] = callback;
|
all_categories['cat' + (level + 1)] = callback;
|
||||||
})
|
})
|
||||||
level++;
|
level++;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
crud({'level': level, "cat": ""}, '/class/ajaxCategory', 'POST', function (callback) {
|
crudAjax({'level': level, "cat": ""}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
all_categories['cat' + (level + 1)] = callback;
|
all_categories['cat' + (level + 1)] = callback;
|
||||||
})
|
})
|
||||||
level++;
|
level++;
|
||||||
@ -100,7 +88,7 @@ function selectedValue() {
|
|||||||
|
|
||||||
scroolToSelect(all_category_box)
|
scroolToSelect(all_category_box)
|
||||||
|
|
||||||
crud({"cat": value[0], 'level': level}, '/class/ajaxCategory', 'POST', function (callback) {
|
crudAjax({"cat": value[0], 'level': level}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
if (callback.length <= 0) {
|
if (callback.length <= 0) {
|
||||||
$('.category-row').append(completedField());
|
$('.category-row').append(completedField());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -7,18 +7,6 @@ $('.edit-category-filter-modal').on('click', function () {
|
|||||||
$('#categoryModal').modal('toggle');
|
$('#categoryModal').modal('toggle');
|
||||||
})
|
})
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
async: false,
|
|
||||||
data: params,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var level = 0;
|
var level = 0;
|
||||||
var id_list = categories;
|
var id_list = categories;
|
||||||
var selected;
|
var selected;
|
||||||
@ -27,7 +15,7 @@ var all_categories = {};
|
|||||||
var promiseForCategory = new Promise(function (resolve) {
|
var promiseForCategory = new Promise(function (resolve) {
|
||||||
if (categories.length != 0) {
|
if (categories.length != 0) {
|
||||||
$.each(categories, function (index, value) {
|
$.each(categories, function (index, value) {
|
||||||
crud({
|
crudAjax({
|
||||||
'level': level,
|
'level': level,
|
||||||
"cat": categories['cat' + level]
|
"cat": categories['cat' + level]
|
||||||
}, '/class/ajaxCategory', 'POST', function (callback) {
|
}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
@ -36,7 +24,7 @@ var promiseForCategory = new Promise(function (resolve) {
|
|||||||
level++;
|
level++;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
crud({'level': level, "cat": ""}, '/class/ajaxCategory', 'POST', function (callback) {
|
crudAjax({'level': level, "cat": ""}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
all_categories['cat' + (level + 1)] = callback;
|
all_categories['cat' + (level + 1)] = callback;
|
||||||
})
|
})
|
||||||
level++;
|
level++;
|
||||||
@ -59,7 +47,7 @@ promiseForCategory.then(function (categories_list) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
level++;
|
level++;
|
||||||
crud({
|
crudAjax({
|
||||||
'level': level,
|
'level': level,
|
||||||
"cat": id_list['cat' + Object.keys(id_list).length]
|
"cat": id_list['cat' + Object.keys(id_list).length]
|
||||||
}, '/class/ajaxCategory', 'POST', function (callback) {
|
}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
@ -112,7 +100,7 @@ function selectedValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
crud({"cat": value, 'level': level}, '/class/ajaxCategory', 'POST', function (callback) {
|
crudAjax({"cat": value, 'level': level}, '/class/ajaxCategory', 'POST', function (callback) {
|
||||||
if (callback.length > 0) {
|
if (callback.length > 0) {
|
||||||
$('.category-row').append(CategoryField('cat' + level, level));
|
$('.category-row').append(CategoryField('cat' + level, level));
|
||||||
$.each(callback, function (index, value) {
|
$.each(callback, function (index, value) {
|
||||||
|
|||||||
@ -210,7 +210,7 @@ function editMarket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCountries() {
|
function getCountries() {
|
||||||
crud('', '/ajax/getCountry', 'GET', function (callback) {
|
crudAjax('', '/ajax/getCountry', 'GET', function (callback) {
|
||||||
$.each(callback, function (index, value) {
|
$.each(callback, function (index, value) {
|
||||||
$('select[name="country"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
$('select[name="country"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,15 +3,3 @@
|
|||||||
// Go!
|
// Go!
|
||||||
|
|
||||||
})(window, document);
|
})(window, document);
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
async: false,
|
|
||||||
data: params,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
function crudAjax(params, url, type, callback, async = false) {
|
||||||
|
return $.ajax({
|
||||||
|
type: type,
|
||||||
|
data: params,
|
||||||
|
async: async,
|
||||||
|
url: url,
|
||||||
|
success: function (response) {
|
||||||
|
callback(response);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -18,6 +18,7 @@
|
|||||||
{{ asset_add("theme.css", "visiosoft.theme.base::css/intlTelInput.css") }}
|
{{ asset_add("theme.css", "visiosoft.theme.base::css/intlTelInput.css") }}
|
||||||
|
|
||||||
<script src="{{ asset_path('visiosoft.theme.base::js/vendor/jquery.min.js') }}"></script>
|
<script src="{{ asset_path('visiosoft.theme.base::js/vendor/jquery.min.js') }}"></script>
|
||||||
|
{{ asset_script('visiosoft.theme.base::js/visiosoft.js') }}
|
||||||
|
|
||||||
{{ asset_style("theme.css") }}
|
{{ asset_style("theme.css") }}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ new Promise(function (resolve, reject) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getCities(country) {
|
function getCities(country) {
|
||||||
crud('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
crudAjax('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="city"]').html("<option value=''>" + pick_option + "</option>");
|
$('select[name="city"]').html("<option value=''>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -41,7 +41,7 @@ function getCities(country) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDistricts(city) {
|
function getDistricts(city) {
|
||||||
crud('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
crudAjax('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="district"]').html("<option value=''>" + pick_option + "</option>");
|
$('select[name="district"]').html("<option value=''>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -53,7 +53,7 @@ function getDistricts(city) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNeighborhoods(district) {
|
function getNeighborhoods(district) {
|
||||||
crud('id=' + district, '/ajax/getNeighborhoods', 'POST', function (callback) {
|
crudAjax('id=' + district, '/ajax/getNeighborhoods', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="neighborhood"]').html("<option value=''>" + pick_option + "</option>");
|
$('select[name="neighborhood"]').html("<option value=''>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -74,15 +74,3 @@ $(document).on('change', 'select[name="city"]', function () {
|
|||||||
$(document).on('change', 'select[name="district"]', function () {
|
$(document).on('change', 'select[name="district"]', function () {
|
||||||
getNeighborhoods($(this).val())
|
getNeighborhoods($(this).val())
|
||||||
});
|
});
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
data: params,
|
|
||||||
async: false,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
function crudAjax(params, url, type, callback, async = false) {
|
function crudAjax(params, url, type, callback, async = false) {
|
||||||
$.ajax({
|
return $.ajax({
|
||||||
type: type,
|
type: type,
|
||||||
data: params,
|
data: params,
|
||||||
async: async,
|
async: async,
|
||||||
|
|||||||
@ -11,4 +11,3 @@
|
|||||||
{{ script|raw }}
|
{{ script|raw }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</script>
|
</script>
|
||||||
{{ asset_script('visiosoft.theme.defaultadmin::js/visiosoft.js') }}
|
|
||||||
|
|||||||
@ -60,6 +60,7 @@
|
|||||||
{{ asset_add("theme.js", "visiosoft.theme.base::js/intlTelInput.min.js") }}
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/intlTelInput.min.js") }}
|
||||||
{{ asset_add("theme.js", "visiosoft.theme.base::js/utils.js") }}
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/utils.js") }}
|
||||||
{{ asset_add("theme.js", "visiosoft.theme.base::js/phonefield.js") }}
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/phonefield.js") }}
|
||||||
|
{{ asset_script('visiosoft.theme.defaultadmin::js/visiosoft.js') }}
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
{{ asset_inline("theme.css") }}
|
{{ asset_inline("theme.css") }}
|
||||||
{{ asset_inline("build.css") }}
|
{{ asset_inline("build.css") }}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ $('.edit-this-address').on('click', function () {
|
|||||||
$("#newAdd-address").attr("action", '/profile/adress/ajaxUpdate/' + edit_address_id);
|
$("#newAdd-address").attr("action", '/profile/adress/ajaxUpdate/' + edit_address_id);
|
||||||
|
|
||||||
//Get Address Detail
|
//Get Address Detail
|
||||||
crud({"id": edit_address_id}, '/profile/adress/ajaxDetail', 'POST', function (callback) {
|
crudAjax({"id": edit_address_id}, '/profile/adress/ajaxDetail', 'POST', function (callback) {
|
||||||
var address_detail = callback.data;
|
var address_detail = callback.data;
|
||||||
var address_field = ['adress_name', 'adress_gsm_phone', 'adress_first_name', 'adress_last_name'];
|
var address_field = ['adress_name', 'adress_gsm_phone', 'adress_first_name', 'adress_last_name'];
|
||||||
|
|
||||||
@ -44,13 +44,13 @@ $('.edit-this-address').on('click', function () {
|
|||||||
$("#newAdd-address").find('select[name="country"]').val(address_detail.country_id)
|
$("#newAdd-address").find('select[name="country"]').val(address_detail.country_id)
|
||||||
|
|
||||||
//Get City Options
|
//Get City Options
|
||||||
crud('id=' + address_detail.country_id, '/ajax/getCities', 'POST',function (callback){
|
crudAjax('id=' + address_detail.country_id, '/ajax/getCities', 'POST',function (callback){
|
||||||
setSelectOptions($("#newAdd-address").find('select[name="city"]'),callback,'id','name');
|
setSelectOptions($("#newAdd-address").find('select[name="city"]'),callback,'id','name');
|
||||||
})
|
})
|
||||||
|
|
||||||
//Get District Options
|
//Get District Options
|
||||||
var selectedCity = new Promise(function (resolve) {
|
var selectedCity = new Promise(function (resolve) {
|
||||||
crud('id=' + address_detail.city, '/ajax/getDistricts', 'POST',function (callback){
|
crudAjax('id=' + address_detail.city, '/ajax/getDistricts', 'POST',function (callback){
|
||||||
setSelectOptions($("#newAdd-address").find('select[name="district"]'),callback,'id','name');
|
setSelectOptions($("#newAdd-address").find('select[name="district"]'),callback,'id','name');
|
||||||
});
|
});
|
||||||
$("#newAdd-address").find('select[name="city"]').val(address_detail.city)
|
$("#newAdd-address").find('select[name="city"]').val(address_detail.city)
|
||||||
@ -77,7 +77,7 @@ $("#newAdd-address").submit(function (e) {
|
|||||||
e.preventDefault(); // avoid to execute the actual submit of the form.
|
e.preventDefault(); // avoid to execute the actual submit of the form.
|
||||||
var form = $(this);
|
var form = $(this);
|
||||||
var url = form.attr('action');
|
var url = form.attr('action');
|
||||||
crud(form.serialize(), url, "POST", function (response) {
|
crudAjax(form.serialize(), url, "POST", function (response) {
|
||||||
if (response.status == "updated") {
|
if (response.status == "updated") {
|
||||||
$('.row-address' + response.data.id).find(".address-title").html(response.data.adress_name)
|
$('.row-address' + response.data.id).find(".address-title").html(response.data.adress_name)
|
||||||
$('#editAddress').modal('hide');
|
$('#editAddress').modal('hide');
|
||||||
|
|||||||
@ -30,7 +30,7 @@ new Promise(function (resolve, reject) {
|
|||||||
|
|
||||||
|
|
||||||
function getCities(country) {
|
function getCities(country) {
|
||||||
crud('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
crudAjax('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="default_city"]').html("<option>" + pick_option + "</option>");
|
$('select[name="default_city"]').html("<option>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -40,7 +40,7 @@ function getCities(country) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDistricts(city) {
|
function getDistricts(city) {
|
||||||
crud('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
crudAjax('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="default_district"]').html("<option>" + pick_option + "</option>");
|
$('select[name="default_district"]').html("<option>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -50,7 +50,7 @@ function getDistricts(city) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNeighborhoods(district) {
|
function getNeighborhoods(district) {
|
||||||
crud('id=' + district, '/ajax/getNeighborhoods', 'POST', function (callback) {
|
crudAjax('id=' + district, '/ajax/getNeighborhoods', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="default_neighborhood"]').html("<option>" + pick_option + "</option>");
|
$('select[name="default_neighborhood"]').html("<option>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -71,16 +71,3 @@ $(document).on('change', 'select[name="default_city"]', function () {
|
|||||||
$(document).on('change', 'select[name="default_district"]', function () {
|
$(document).on('change', 'select[name="default_district"]', function () {
|
||||||
getNeighborhoods($(this).val())
|
getNeighborhoods($(this).val())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
data: params,
|
|
||||||
async: false,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -71,19 +71,8 @@ function numPages() {
|
|||||||
return Math.ceil(totalAdvs / records_per_page);
|
return Math.ceil(totalAdvs / records_per_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
data: params,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMyAdvs(type) {
|
function getMyAdvs(type) {
|
||||||
crud({'type': type, 'paginate': true, 'page': current_page}, '/ajax/getAdvs', 'GET', function (callback) {
|
crudAjax({'type': type, 'paginate': true, 'page': current_page}, '/ajax/getAdvs', 'GET', function (callback) {
|
||||||
ads_type = type;
|
ads_type = type;
|
||||||
objJson = callback.content.data;
|
objJson = callback.content.data;
|
||||||
totalAdvs = callback.content.total
|
totalAdvs = callback.content.total
|
||||||
|
|||||||
@ -54,7 +54,7 @@ phoneMask("input[name='adress_gsm_phone']");
|
|||||||
|
|
||||||
|
|
||||||
function getCountries() {
|
function getCountries() {
|
||||||
crud('', '/ajax/getCountry', 'GET', function (callback) {
|
crudAjax('', '/ajax/getCountry', 'GET', function (callback) {
|
||||||
$('select[name="country"]').html("<option>" + pick_option + "</option>");
|
$('select[name="country"]').html("<option>" + pick_option + "</option>");
|
||||||
$.each(callback, function (index, value) {
|
$.each(callback, function (index, value) {
|
||||||
$('select[name="country"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
$('select[name="country"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||||
|
|||||||
@ -23,7 +23,7 @@ new Promise(function (resolve, reject) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getCities(country) {
|
function getCities(country) {
|
||||||
crud('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
crudAjax('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="city"]').html("<option>" + pick_option + "</option>");
|
$('select[name="city"]').html("<option>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -33,7 +33,7 @@ function getCities(country) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDistricts(city) {
|
function getDistricts(city) {
|
||||||
crud('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
crudAjax('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
||||||
cities = callback;
|
cities = callback;
|
||||||
$('select[name="district"]').html("<option>" + pick_option + "</option>");
|
$('select[name="district"]').html("<option>" + pick_option + "</option>");
|
||||||
$.each(cities, function (index, value) {
|
$.each(cities, function (index, value) {
|
||||||
@ -49,16 +49,3 @@ $(document).on('change', 'select[name="country"]', function () {
|
|||||||
$(document).on('change', 'select[name="city"]', function () {
|
$(document).on('change', 'select[name="city"]', function () {
|
||||||
getDistricts($(this).val())
|
getDistricts($(this).val())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
|
||||||
$.ajax({
|
|
||||||
type: type,
|
|
||||||
data: params,
|
|
||||||
async: false,
|
|
||||||
url: url,
|
|
||||||
success: function (response) {
|
|
||||||
callback(response);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user