"use strict";define(["app","handlebars","View","../Models/PatientOrientationModel","../../../../components/Confirmation/Controllers/ConfirmationController","text!/v2/webapps/FirstAccess/AdminSettings/Templates/PatientOrientationViewTemplate.html","utils"],function(d,h,g,e,b,c,a){var f=g.extend({template:h.compile(c),data:undefined,selectedPatientOrientationLang:"ENG",events:{"click .btn.add, .edit-btn":"clickPatientOrientation","click .btn.delete-btn":"clickDeletePatientOrientation","change #languageMap":"onChangePatientOrientationLang"},initialize:function(i){g.prototype.initialize.apply(this,arguments);this.options=i||{};this.data=undefined;},render:function(j){var i=_.map(j.Statuses,function(k){return k.Description;});if(!_.contains(i,a.localize(this,["adminsetting.noStatusChange"]))){j.Statuses.unshift({Description:a.localize(this,["adminsetting.noStatusChange"])});}j.Statuses=$.map(j.Statuses,function(k){k.selected=(k.Status===j.PatientStatus);return k;});j.language=j.language?j.language:j.DefaultLanguage;j.Languages=$.map(j.Languages,function(k){return{langCd:k,name:"adminsetting.languagesView.language."+k,selected:j.language===k};});j.OrientationRecords=_.sortBy(j.OrientationRecords,function(k){return k.Order;});this.$el.html(this.template(j));this.$el.find("tbody").sortable({stop:function(k,l){$(this).find("tr").each(function(o){var m=o+1;$(this).find("td:nth-child(1) .order").text(m);var n=_.findWhere(j.OrientationRecords,{Id:this.id});if(n.Order!==m){n.Action=e.CRUD_ENUMS.MODIFY;n.state=e.CRUD_ENUMS.MODIFY;}n.Order=m;n.state=n.state===e.CRUD_ENUMS.READ?e.CRUD_ENUMS.MODIFY:n.state;});}}).find("td").each(function(l,m){var k=$(m);if(k.is(".text")===true){var n=k.text().trim();k.attr("data-toggle","tooltip");k.attr("data-placement","auto bottom");k.attr("title",n);if(n&&n.length>60){k.text(n.substring(0,60)+"...");}}});this.data=j;return this;},clickDeletePatientOrientation:function(j){j.preventDefault();var i=new b();i.open({parent:this,header:a.localize(this,["adminsetting.deleterecord"]),message:a.localize(this,["adminglobal.deleteconfirm"])},_.bind(function(k){if(k===true){var l=$(j.target).closest("tr").attr("id");this.trigger("view:deletePatientOrientation",l);}},this));},clickPatientOrientation:function(i){i.preventDefault();var j=$(i.target).closest("tr").attr("id");this.trigger("view:editPatientOrientation",{Id:j,OrientationRecords:this.data.OrientationRecords});return false;},onChangePatientOrientationLang:function(i){i.preventDefault();this.trigger("view:rerenderPatientOrientation");}});return f;});