Commit 8b097675 authored by Marko Kuder's avatar Marko Kuder
Browse files

copy hidden fields when updating resource

parent 155ab993
......@@ -755,6 +755,10 @@ CKAN.Dgu = function($, my) {
var formatInput = $(button).closest("td").siblings(".resource-format").find("input").val();
var $dateInput = $(button).closest("td").siblings(".resource-date").find("input");
var date = $dateInput.length === 0 ? '' : $dateInput.val();
var $urlTypeInput = $(button).closest("tr").find(".resource-url-type").find("input");
var url_type = $urlTypeInput.length === 0 ? '' : $urlTypeInput.val();
var $nameInput = $(button).closest("tr").find(".resource-name").find("input");
var name = $nameInput.length === 0 ? '' : $nameInput.val();
var refreshInterval = $('#pogostost_osvezevanja').children(":selected").val();
var valid = true;
......@@ -787,17 +791,32 @@ CKAN.Dgu = function($, my) {
}
if (valid) {
isUploadingUrl = true;
resource_data = {
"id": resourceId,
"package_id": packageId,
"url": urlResourceValue[0],
"description": descriptionInput,
"pogostost_osvezevanja": refreshInterval,
"format": formatInput,
"resource_type": resourceType
}
//copy hidden input fields of existing resources
if (name != '') {
resource_data["name"] = name;
}
if (url_type != '') {
resource_data["url_type"] = url_type;
}
//copy date for timeseries
if (date != '') {
resource_data["date"] = date;
}
if (resourceId.length !== 0) {
$.ajax({
url: "/api/3/action/resource_update",
dataType: 'json',
data: '{"id": "'+ resourceId
+ '", "package_id": "' + packageId
+ '", "url": "' + urlResourceValue[0]
+ '", "description": ' + JSON.stringify(descriptionInput)
+ ', "date": "' + date
+ '", "pogostost_osvezevanja": "' + refreshInterval
+ '", "format": "' + formatInput + '"}',
data: JSON.stringify(resource_data),
cache: false,
type: "POST",
success: function(data) {
......@@ -836,13 +855,7 @@ CKAN.Dgu = function($, my) {
$.ajax({
url: "/api/3/action/resource_create",
dataType: 'json',
data: '{"package_id": "' + packageId
+ '", "url": "' + urlResourceValue[0]
+ '", "description": "' + descriptionInput
+ '", "date": "' + date
+ '", "pogostost_osvezevanja": "' + refreshInterval
+ '", "format": "' + formatInput
+ '", "resource_type": "' + resourceType + '"}',
data: JSON.stringify(resource_data),
cache: false,
type: "POST",
success: function (data) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment