{if $input.sourceId} {tr}Join{/tr} {/if}
{jq} $('.map-join .service-dialog-edit').click(function () { $clicked = $(this); $.getJSON('tiki-searchindex.php', { filter: { object_type:"trackeritem", object_id:{{$input.sourceId}} }, fields:["tracker_field_mapName","tracker_field_mapDescription","tracker_field_shareCode","tracker_field_mapDetailsHeader","tracker_field_mapBaseLocation","tracker_field_owner"] }, function (data) { if (!!data) { // now take the results data, create a fake anchor and trigger the insert_item service dialog (must be an easier way, no?) var result = data[0]; $.getJSON($.service('tracker', 'list_fields'), { trackerId: {{$input.trackerId}} }, function (data) { // need the ins_ id's from the fields var fields = data.fields; var fld, input = { status: result.tracker_status }; for (fld in fields) { switch(fields[fld].permName) { case "owner": input["ins_" + fields[fld].fieldId] = result.tracker_field_owner; break; case "owner": input["ins_" + fields[fld].fieldId] = result.tracker_field_owner; break; case "shareCode": input["ins_" + fields[fld].fieldId] = result.tracker_field_shareCode; break; case "mapName": input["ins_" + fields[fld].fieldId] = result.tracker_field_mapName + " " + "{tr}joined by{/tr} {{$input.owner}}"; break; case "mapDescription": input["ins_" + fields[fld].fieldId] = result.tracker_field_mapDescription; break; case "mapBaseLocation": input["ins_" + fields[fld].fieldId] = result.tracker_field_mapBaseLocation; break; default: break; } } $clicked.parent().append($('{{tr}}Join{{/tr}}'). serviceDialog({ title: $(this).text(), data: input, success: function (data) { var url = "Map?mapId=@itemId@&coordinates=@mapBaseLocation@&shareCode=@shareCode@&mapName=@mapName@" .replace("@itemId@", escape(data.itemId)); $.each(data.fields, function (k, v) { url = url.replace("@" + k + "@", escape(v)); }); document.location.href = url + "#Map"; } }).click() ); }); } } ); // // clone via GET doesn't clone child items // $.getJSON($.service("tracker", "clone_item"), { // trackerId:{{$input.trackerId}}, // itemId:{{$input.sourceId}}, // owner:"{{$input.owner}}", // fields:["mapName","mapDescription","shareCode","mapDetailsHeader","mapBaseLocation","owner"] // }, function(data) { // debugger; // } // ); // $(this).serviceDialog({ // title: $(this).text(), // success: function (data) { // var url = "Map?mapId=@itemId@&coordinates=@mapBaseLocation@&shareCode=@shareCode@&mapName=@mapName@" // .replace("@itemId@", escape(data.itemId)); // // $.each(data.fields, function () { // url = url.replace("@" + this.permName + "@", escape(this.value)); // }); // // document.location.href = url; // } // }); return false; }); {/jq}