(function(){"use strict";$.extend(page,{"Form.onCreate":function(o){if(o.formName.endsWith("Invitation")){e(o)}else if(o.formName.endsWith("Feedback")){i(o)}if(page.popup){page.popup.autoSizeAndPosition()}},"Form.onWidgetPreCreate":function(e,o){if(o.widgetId!=="response"){return}var r=e.widgets[o.widgetId];var i=t(e);r.options.model.reader.options.defaultsFromRecord.uid=i}});$.extend(page.commandBindings,{"Social/SendResponse":function(e,r,i){var a=u8.Base.Widgets.Tools.closest(e,"Form"),d=o(a,i.commandArguments),u=t(a);n(a,null);var l=a.busy();u8.services.social.sendResponse(u,{response:d},function(e,o){l.hide();if(o.error){n(a,o.error)}else{s(a)}})},"Social/SendInvitation":function(e,r,i){var a=u8.Base.Widgets.Tools.closest(e,"Form"),d=o(a,i.commandArguments),u=t(a);n(a,null);var l=a.busy();u8.services.social.sendInvitation(u,{invitation:d},function(e,o){l.hide();if(o.error){n(a,o.error)}else{s(a)}})},"Social/SendFeedback":function(e,r,i){var a=u8.Base.Widgets.Tools.closest(e,"Form"),d=o(a,i.commandArguments),u=t(a);n(a,null);var l=a.busy();u8.services.social.sendFeedback(u,{feedback:d},function(e,o){l.hide();if(o.error){n(a,o.error)}else{s(a)}})}});function e(e){var o=t(e),i=page.url.get("communityTarget");if(!i){return}u8.services.social.createInvitation(o,i,function(o,i){if(i.error){return}r(e,i)})}function o(e,o){o=$.extend({},o,e.context.getProperties());var r=e.getWidget("response");if(r){var i=r.model.getItem().businessObject;o.fields=i.values}return o}function r(e,o){if(!o){return}var r=e.getWidget("response");if(!r){return}var i=o.fields;if(i){var t=r.model;var n=t.isModified();for(var s in i){var a=i[s];t.setFieldValue("Root",s,a)}if(!n){t.clearModified()}}}function i(e){var o=page.url.getBoolean("autoCopyFeedback",true);if(!o){return}var r=e.getWidget("message"),i=e.getWidget("response");if(!r||!i){return}var t=r.model.getItem().businessObject.values;for(var n in t){var s=t[n];i.model.setFieldValue("Root",n,s)}var a=r.model.getItem("TW");if(a){var d={Feedback:"Content"};for(var u in d){var l=r.model.getFieldValue("TW",u);if(l){i.model.setFieldValue("Root",d[u],l)}}}}function t(e){return e.getComponent("url").getUid()}function n(e,o){var r=e.getWidget("response");if(!r){return}r.notify(o);if(o){o.handled=true}}function s(e){var o=e.getWidget("response");if(o){o.model.clearModified()}$command(e,"Close")}})();