From: Jason Skomorowski Date: Thu, 28 Aug 2014 01:55:21 +0000 (-0400) Subject: Detail record selection for mwksbiblio X-Git-Url: http://git.indexdata.com/?p=mkwsxb-moved-to-github.git;a=commitdiff_plain;h=0fe33f3a7c8ec889087c80bed452c863ba907558 Detail record selection for mwksbiblio --- diff --git a/mkwsbiblio/mkwsbiblio/mkwsbiblio.py b/mkwsbiblio/mkwsbiblio/mkwsbiblio.py index 83bc12a..3faa320 100644 --- a/mkwsbiblio/mkwsbiblio/mkwsbiblio.py +++ b/mkwsbiblio/mkwsbiblio/mkwsbiblio.py @@ -16,6 +16,11 @@ class MKWSBiblio(XBlock): default="water", scope=Scope.content ) + recid = String( + help="Record to display", + default="content: title modern water resources engineering", + scope=Scope.content + ) display_name = String( default="MKWS bibliographic details", scope=Scope.settings @@ -29,12 +34,14 @@ class MKWSBiblio(XBlock): def student_view(self, context=None): """The primary view of the MKWS XBlock, shown to students when viewing courses.""" html = self.resource_string("static/html/student.html") - frag = Fragment(html.format(query=self.query, team=random.randint(0, 100000))) + frag = Fragment(html.format(query=self.query, recid=self.recid, team=random.randint(0, 100000))) # student.js uses require.js as it cannot guarantee mkws-complete.js has loaded # in studio without it. We'll need to add it if we're in the LMS: - frag.add_javascript_url("/static/js/vendor/require.js"); + #frag.add_javascript_url("/static/js/vendor/require.js"); + frag.add_javascript_url("//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.14/require.min.js"); # frag.add_resource_url("//mkws.indexdata.com/mkws-complete", "text/javascript", "head"); # frag.add_resource('', "text/html", "head"); + frag.add_css(self.resource_string("static/css/mkwsbiblio.css")) frag.add_javascript(self.resource_string("static/js/src/student.js")) frag.initialize_js('MKWSBiblio') return frag; @@ -44,7 +51,8 @@ class MKWSBiblio(XBlock): # This should closely mirror the student_view. Here all we do is not include # require.js as it's already in Studio and the lms path won't work. html = self.resource_string("static/html/student.html") - frag = Fragment(html.format(query=self.query, team=random.randint(0, 100000))) + frag = Fragment(html.format(query=self.query, recid=self.recid, team=random.randint(0, 100000))) + frag.add_css(self.resource_string("static/css/mkwsbiblio.css")) frag.add_javascript(self.resource_string("static/js/src/student.js")) frag.initialize_js('MKWSBiblio') return frag; @@ -52,7 +60,7 @@ class MKWSBiblio(XBlock): def studio_view(self, context=None): """Studio configuration view.""" html = self.resource_string("static/html/settings.html") - frag = Fragment(html.format(query=self.query)) + frag = Fragment(html.format(query=self.query, recid=self.recid)) frag.add_javascript(self.resource_string("static/js/settings.js")) frag.initialize_js('MKWSBiblioSettings') return frag @@ -61,6 +69,7 @@ class MKWSBiblio(XBlock): def update_settings(self, data, suffix=''): """Studio configuration callback.""" self.query = data['query'] + self.recid = data['recid'] return {"result": "success"} @staticmethod diff --git a/mkwsbiblio/mkwsbiblio/static/css/mkwsbiblio.css b/mkwsbiblio/mkwsbiblio/static/css/mkwsbiblio.css new file mode 100644 index 0000000..f47acb2 --- /dev/null +++ b/mkwsbiblio/mkwsbiblio/static/css/mkwsbiblio.css @@ -0,0 +1,8 @@ +.mkwsDetails th { + text-align: right; + vertical-align: top; + padding-right: 0.6em; +} +.mkwsDetails th:after { + content: ":"; +} diff --git a/mkwsbiblio/mkwsbiblio/static/html/settings.html b/mkwsbiblio/mkwsbiblio/static/html/settings.html index 6e0ab63..e6984a4 100644 --- a/mkwsbiblio/mkwsbiblio/static/html/settings.html +++ b/mkwsbiblio/mkwsbiblio/static/html/settings.html @@ -2,8 +2,7 @@ diff --git a/mkwsbiblio/mkwsbiblio/static/html/student.html b/mkwsbiblio/mkwsbiblio/static/html/student.html index 6df95ba..b8f2e61 100644 --- a/mkwsbiblio/mkwsbiblio/static/html/student.html +++ b/mkwsbiblio/mkwsbiblio/static/html/student.html @@ -1,3 +1,3 @@
-
Loading record...
+
Loading record...
diff --git a/mkwsbiblio/mkwsbiblio/static/js/settings.js b/mkwsbiblio/mkwsbiblio/static/js/settings.js index f238e6c..50de002 100644 --- a/mkwsbiblio/mkwsbiblio/static/js/settings.js +++ b/mkwsbiblio/mkwsbiblio/static/js/settings.js @@ -16,11 +16,9 @@ function program1(depth0,data) { if (helper = helpers.detailLinkId) { stack1 = helper.call(depth0, {hash:{},data:data}); } else { helper = (depth0 && depth0.detailLinkId); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } buffer += escapeExpression(stack1) - + "\" onclick=\"$('#mkwsCurrentRecord').attr('autosearch', '"; - if (helper = helpers['md-title']) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0['md-title']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - buffer += escapeExpression(stack1) - + "'); mkws.init('Click select', $('#mkwsCurrentRecordContainer'));\">\n "; + + "\" onclick=\" $('#mkwsCurrentRecord').attr('data-mkws-recid', '" + + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.recid)),stack1 == null || stack1 === false ? stack1 : stack1[0])),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + + "'); $('#mkwsCurrentRecord').attr('autosearch', mkws.teams['BlockConfig'].query()); delete mkws.teams.ConfiguredRecord; mkws.init('Click select', '#mkwsCurrentRecordContainer'); return false;\">\n "; if (helper = helpers['md-title']) { stack1 = helper.call(depth0, {hash:{},data:data}); } else { helper = (depth0 && depth0['md-title']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } buffer += escapeExpression(stack1) @@ -76,19 +74,38 @@ function program6(depth0,data) { return buffer; }); })(); +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +templates['EdxChosen'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; +helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression; + + + buffer += "Current selection: "; + if (helper = helpers['md-title']) { stack1 = helper.call(depth0, {hash:{},data:data}); } + else { helper = (depth0 && depth0['md-title']); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } + buffer += escapeExpression(stack1) + + "\n"; + return buffer; + }); +})(); function MKWSBiblioSettings(runtime, element) { mkws.init("XBlock settings pane", "#settings-tab"); $(element).find('.save-button').bind('click', function() { var handlerUrl = runtime.handlerUrl(element, 'update_settings'); var data = { - query: $(element).find('#mkwsCurrentRecord').attr('autosearch') + query: mkws.teams["BlockConfig"].query(), + recid: $(element).find('#mkwsCurrentRecord').attr('data-mkws-recid') }; $.post(handlerUrl, JSON.stringify(data)).done(function(response) { window.location.reload(false); + return false; }); }); $(element).find('.cancel-button').bind('click', function() { runtime.notify('cancel', {}); + return false; }); -}; +} diff --git a/mkwsbiblio/mkwsbiblio/static/js/src/EdxChooser.handlebars b/mkwsbiblio/mkwsbiblio/static/js/src/EdxChooser.handlebars index e3f8656..60ede8d 100644 --- a/mkwsbiblio/mkwsbiblio/static/js/src/EdxChooser.handlebars +++ b/mkwsbiblio/mkwsbiblio/static/js/src/EdxChooser.handlebars @@ -10,7 +10,7 @@ hits: }} {{#each hits}}
- + {{md-title}} {{#if md-title-remainder}} diff --git a/mkwsbiblio/mkwsbiblio/static/js/src/EdxChosen.handlebars b/mkwsbiblio/mkwsbiblio/static/js/src/EdxChosen.handlebars new file mode 100644 index 0000000..3a972ef --- /dev/null +++ b/mkwsbiblio/mkwsbiblio/static/js/src/EdxChosen.handlebars @@ -0,0 +1 @@ +Current selection: {{md-title}} diff --git a/mkwsbiblio/mkwsbiblio/static/js/src/settings.js b/mkwsbiblio/mkwsbiblio/static/js/src/settings.js index 3d8e2d7..7bfa8d8 100644 --- a/mkwsbiblio/mkwsbiblio/static/js/src/settings.js +++ b/mkwsbiblio/mkwsbiblio/static/js/src/settings.js @@ -3,14 +3,17 @@ function MKWSBiblioSettings(runtime, element) { $(element).find('.save-button').bind('click', function() { var handlerUrl = runtime.handlerUrl(element, 'update_settings'); var data = { - query: $(element).find('#mkwsCurrentRecord').attr('autosearch') + query: mkws.teams["BlockConfig"].query(), + recid: $(element).find('#mkwsCurrentRecord').attr('data-mkws-recid') }; $.post(handlerUrl, JSON.stringify(data)).done(function(response) { window.location.reload(false); + return false; }); }); $(element).find('.cancel-button').bind('click', function() { runtime.notify('cancel', {}); + return false; }); -}; +} diff --git a/mkwsbiblio/mkwsbiblio/static/js/src/student.js b/mkwsbiblio/mkwsbiblio/static/js/src/student.js index 406407c..a2770b7 100644 --- a/mkwsbiblio/mkwsbiblio/static/js/src/student.js +++ b/mkwsbiblio/mkwsbiblio/static/js/src/student.js @@ -1,7 +1,8 @@ window.mkws_noready = true; require.config({ paths: { - mkws: "//mkws.local/mkws-complete", + //mkws: "//mkws.local/mkws-complete", + mkws: "//mkws.indexdata.com/mkws-compl-tmpl", }, shim: { mkws: {