Parcourir la source

Download reports in mobile

version-14
Faris Ansari il y a 7 ans
Parent
révision
1898f5f8e1
2 fichiers modifiés avec 37 ajouts et 5 suppressions
  1. +27
    -4
      frappe/public/js/frappe/query_string.js
  2. +10
    -1
      frappe/public/js/legacy/handler.js

+ 27
- 4
frappe/public/js/frappe/query_string.js Voir le fichier

@@ -1,3 +1,5 @@
frappe.provide('frappe.utils');

function get_url_arg(name) {
return get_query_params()[name] || "";
}
@@ -36,8 +38,29 @@ function get_query_params(query_string) {
return query_params;
}

function make_query_string(obj) {
var query_params = [];
$.each(obj, function(k, v) { query_params.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); });
return "?" + query_params.join("&");
function make_query_string(obj, encode=true) {
let query_params = [];
for (let key in obj) {
let value = obj[key];
if (value === undefined || value === '' || value === null) {
continue;
}
if (typeof value === 'object') {
value = JSON.stringify(value);
}

if (encode) {
key = encodeURIComponent(key);
value = encodeURIComponent(value);
}

query_params.push(`${key}=${value}`);
}
return '?' + query_params.join('&');
}

Object.assign(frappe.utils, {
get_url_arg,
get_query_params,
make_query_string
});

+ 10
- 1
frappe/public/js/legacy/handler.js Voir le fichier

@@ -62,8 +62,17 @@ function $c_obj_csv(doc, method, arg) {
open_url_post(frappe.request.url, args);
}

// call a url as POST
function open_url_post(URL, PARAMS, new_window) {
if (window.cordova) {
let url = URL + 'api/method/' + PARAMS.cmd + frappe.utils.make_query_string(PARAMS, false);
window.location.href = url;
} else {
// call a url as POST
_open_url_post(URL, PARAMS, new_window);
}
}

function _open_url_post(URL, PARAMS, new_window) {
var temp=document.createElement("form");
temp.action=URL;
temp.method="POST";


Chargement…
Annuler
Enregistrer