5555 .ClientEvents (events =>
5656 {
5757 events .OnDataBound (" grid_subjects_onDataBound" );
58- }))
58+ }))
59+
60+
61+
62+ @section Scripts
63+ {
64+ <script src =" @Url.Content(" ~ /Scripts /2013.2.611 /telerik.common.min.js " )" type =" text/javascript" ></script >
65+ <script src =" @Url.Content(" ~ /Scripts /2013.2.611 /telerik.draganddrop.min.js " )" type =" text/javascript" ></script >
66+ <script src =" @Url.Content(" ~ /Scripts /2013.2.611 /telerik.window.min.js " )" type =" text/javascript" ></script >
67+
68+ <script type =" text/javascript" >
69+
70+ $ (" #treeView_entities li div" )
71+ .click (function (e ) {
72+ $ (e .target ).find (" .t-in" ).trigger (" click" );
73+ });
74+
75+ function getTreeView () {
76+ return $ (' #treeView_entities' ).data (' tTreeView' );
77+ }
78+
79+ function treeView_entities_onSelect (e ) {
80+ var entityId = getTreeView ().getItemValue (e .item );
81+ var prevSelectedDiv = $ (" .bx-selected" );
82+ if (prevSelectedDiv .length > 0 ) $ (prevSelectedDiv).removeClass (" bx-selected" );
83+
84+ var selectedDiv = $ (e .item ).find (" div" )[0 ];
85+ $ (selectedDiv).addClass (" bx-selected" );
86+
87+ $ (' #content_instances' ).empty ();
88+
89+ $ .get (' @Url.Action("Instances", "EntityPermissions")' ,
90+ { EntityId: entityId },
91+ function (contentData ) {
92+
93+ $ (' #content_instances' ).html (contentData);
94+
95+ truncateTitle ();
96+ });
97+ }
98+
99+ function grid_instances_onDataBound () {
100+ addTooltips ();
101+ resetAllTelerikIconTitles ();
102+
103+ $ (" #grid_instances" )
104+ .on (" change" ,
105+ " input[name='selectedInstances']:checkbox" ,
106+ function (e ) {
107+ if ($ (this ).is (' :checked' )) {
108+ $ .post (' @Url.Action("AddInstanceToPublic", "EntityPermissions")' ,
109+ { EntityId: $ (this ).data (' entityid' ), InstanceId: $ (this ).data (' instanceid' ) },
110+ function () {
111+ $ (" #grid_subjects .t-refresh" ).trigger (' click' );
112+ $ (" #grid_instances .t-refresh" ).trigger (' click' );
113+ });
114+ } else {
115+ $ .post (' @Url.Action("RemoveInstanceFromPublic", "EntityPermissions")' ,
116+ { EntityId: $ (this ).data (' entityid' ), InstanceId: $ (this ).data (' instanceid' ) },
117+ function () {
118+ $ (" #grid_subjects .t-refresh" ).trigger (' click' );
119+ $ (" #grid_instances .t-refresh" ).trigger (' click' );
120+ });
121+ }
122+ });
123+ }
124+
125+ function grid_instances_onRowSelect (e ) {
126+ $ .get (' @Url.Action("Subjects", "EntityPermissions")' ,
127+ {
128+ EntityId: $ (" input[name='selectedInstances']:checkbox" , e .row ).data (' entityid' ),
129+ InstanceId: $ (" input[name='selectedInstances']:checkbox" , e .row ).data (' instanceid' )
130+ },
131+ function (data ) {
132+ $ (' #content_subjects' ).empty ();
133+ $ (' #content_subjects' ).html (data);
134+ });
135+ }
136+
137+ function grid_subjects_onDataBound () {
138+ addTooltips ();
139+ resetAllTelerikIconTitles ();
140+
141+ $ (" #grid_subjects tbody input:checkbox" ).click (function () {
142+ if ($ (this ).is (' :checked' )) {
143+ $ .post (' @Url.Action("AddRightToEntityPermission", "EntityPermissions")' ,
144+ { SubjectId: $ (this ).data (' subjectid' ), EntityId: $ (this ).data (' entityid' ), InstanceId: $ (this ).data (' instanceid' ), RightType: $ (this ).data (' righttype' ) },
145+ function () {
146+ $ (" #grid_subjects .t-refresh" ).trigger (' click' );
147+ });
148+ } else {
149+ $ .post (' @Url.Action("RemoveRightFromEntityPermission", "EntityPermissions")' ,
150+ { SubjectId: $ (this ).data (' subjectid' ), EntityId: $ (this ).data (' entityid' ), InstanceId: $ (this ).data (' instanceid' ), RightType: $ (this ).data (' righttype' ) },
151+ function () {
152+ $ (" #grid_subjects .t-refresh" ).trigger (' click' );
153+ });
154+ }
155+ });
156+ }
157+
158+ function grid_subjects_onRowSelect (e ) {
159+ console .log (e .row );
160+ $ .ajax ({
161+ type: ' GET' ,
162+ url: ' @Url.Action("Permissions", "EntityPermissions")' ,
163+ data: { SubjectId: $ (" input" , e .row ).data (' subjectid' ), EntityId: $ (" input" , e .row ).data (' entityid' ), InstanceId: $ (" input" , e .row ).data (' instanceid' ) },
164+ dataType: ' html' ,
165+ success : function (htmlData ) {
166+ var windowElement = $ .telerik .window .create ({
167+ title: " Permissions: " + $ (" input" , e .row ).data (' title' ),
168+ html: " <div id='content_permissions' class='bx-window'>" + htmlData + " </div>" ,
169+ contentUrl: " " ,
170+ actions: [" Close" ],
171+ modal: true ,
172+ width: 500 ,
173+ height: 500 ,
174+ resizable: false ,
175+ draggable: true ,
176+ scrollable: false ,
177+ onClose : function () {
178+ $ (" #window_permissions" ).data (' tWindow' ).destroy ();
179+ $ (" #grid_subjects .t-refresh" ).trigger (' click' );
180+ }
181+ });
182+
183+ windowElement .attr (' id' , ' window_permissions' );
184+ var window = $ (windowElement).data (' tWindow' );
185+ window .center ().open ();
186+
187+ resetAllTelerikIconTitles ();
188+ }
189+ });
190+ }
191+
192+ function grid_permissions_onDataBound () {
193+ addTooltips ();
194+ resetAllTelerikIconTitles ();
195+ }
196+ </script >
197+ }
0 commit comments