publish_my_data 0.0.32 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/publish_my_data/small-spinner.gif +0 -0
- data/app/assets/images/publish_my_data/sort-asc.gif +0 -0
- data/app/assets/images/publish_my_data/sort-desc.gif +0 -0
- data/app/assets/javascripts/bootstrap/affix.js +126 -0
- data/app/assets/javascripts/bootstrap/alert.js +98 -0
- data/app/assets/javascripts/bootstrap/button.js +109 -0
- data/app/assets/javascripts/bootstrap/carousel.js +217 -0
- data/app/assets/javascripts/bootstrap/collapse.js +179 -0
- data/app/assets/javascripts/bootstrap/dropdown.js +154 -0
- data/app/assets/javascripts/bootstrap/modal.js +246 -0
- data/app/assets/javascripts/bootstrap/popover.js +117 -0
- data/app/assets/javascripts/bootstrap/scrollspy.js +158 -0
- data/app/assets/javascripts/bootstrap/tab.js +135 -0
- data/app/assets/javascripts/bootstrap/tooltip.js +386 -0
- data/app/assets/javascripts/bootstrap/transition.js +56 -0
- data/app/assets/javascripts/publish_my_data/grid/10_data-loader.js +142 -0
- data/app/assets/javascripts/publish_my_data/grid/20_cube-grid.js +512 -0
- data/app/assets/javascripts/publish_my_data/grid/30_cube-dimension.js +77 -0
- data/app/assets/javascripts/publish_my_data/grid/40_cube-dimension-dropdown.js +87 -0
- data/app/assets/javascripts/publish_my_data/grid/45_cube-dimension-label.js +58 -0
- data/app/assets/javascripts/publish_my_data/grid/50_cube-dimensions-controls.js +336 -0
- data/app/assets/javascripts/publish_my_data/grid/60_dataset_cube_grid.js +187 -0
- data/app/assets/javascripts/publish_my_data/grid/70_sparql_results_grid.js +135 -0
- data/app/assets/javascripts/publish_my_data/select_text.js +27 -0
- data/app/assets/javascripts/publish_my_data.js +3 -0
- data/app/assets/javascripts/slick_grid/10_event-drag.js +402 -0
- data/app/assets/javascripts/slick_grid/20_slick-core.js +458 -0
- data/app/assets/javascripts/slick_grid/30_slick-grid.js +3295 -0
- data/app/assets/stylesheets/bootstrap/_alerts.scss +67 -0
- data/app/assets/stylesheets/bootstrap/_badges.scss +51 -0
- data/app/assets/stylesheets/bootstrap/_breadcrumbs.scss +23 -0
- data/app/assets/stylesheets/bootstrap/_button-groups.scss +248 -0
- data/app/assets/stylesheets/bootstrap/_buttons.scss +160 -0
- data/app/assets/stylesheets/bootstrap/_carousel.scss +209 -0
- data/app/assets/stylesheets/bootstrap/_close.scss +33 -0
- data/app/assets/stylesheets/bootstrap/_code.scss +56 -0
- data/app/assets/stylesheets/bootstrap/_component-animations.scss +29 -0
- data/app/assets/stylesheets/bootstrap/_dropdowns.scss +194 -0
- data/app/assets/stylesheets/bootstrap/_forms.scss +350 -0
- data/app/assets/stylesheets/bootstrap/_glyphicons.scss +232 -0
- data/app/assets/stylesheets/bootstrap/_grid.scss +346 -0
- data/app/assets/stylesheets/bootstrap/_input-groups.scss +127 -0
- data/app/assets/stylesheets/bootstrap/_jumbotron.scss +40 -0
- data/app/assets/stylesheets/bootstrap/_labels.scss +58 -0
- data/app/assets/stylesheets/bootstrap/_list-group.scss +88 -0
- data/app/assets/stylesheets/bootstrap/_media.scss +56 -0
- data/app/assets/stylesheets/bootstrap/_mixins.scss +728 -0
- data/app/assets/stylesheets/bootstrap/_modals.scss +145 -0
- data/app/assets/stylesheets/bootstrap/_navbar.scss +625 -0
- data/app/assets/stylesheets/bootstrap/_navs.scss +229 -0
- data/app/assets/stylesheets/bootstrap/_normalize.scss +396 -0
- data/app/assets/stylesheets/bootstrap/_pager.scss +55 -0
- data/app/assets/stylesheets/bootstrap/_pagination.scss +83 -0
- data/app/assets/stylesheets/bootstrap/_panels.scss +148 -0
- data/app/assets/stylesheets/bootstrap/_popovers.scss +133 -0
- data/app/assets/stylesheets/bootstrap/_print.scss +100 -0
- data/app/assets/stylesheets/bootstrap/_progress-bars.scss +95 -0
- data/app/assets/stylesheets/bootstrap/_responsive-utilities.scss +209 -0
- data/app/assets/stylesheets/bootstrap/_scaffolding.scss +130 -0
- data/app/assets/stylesheets/bootstrap/_tables.scss +236 -0
- data/app/assets/stylesheets/bootstrap/_theme.scss +232 -0
- data/app/assets/stylesheets/bootstrap/_thumbnails.scss +31 -0
- data/app/assets/stylesheets/bootstrap/_tooltip.scss +95 -0
- data/app/assets/stylesheets/bootstrap/_type.scss +238 -0
- data/app/assets/stylesheets/bootstrap/_utilities.scss +42 -0
- data/app/assets/stylesheets/bootstrap/_variables.scss +620 -0
- data/app/assets/stylesheets/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/bootstrap/bootstrap.scss +59 -0
- data/app/assets/stylesheets/publish_my_data/core.scss +244 -0
- data/app/assets/stylesheets/publish_my_data/data_grid.scss +103 -0
- data/app/assets/stylesheets/publish_my_data/variables.scss +1 -0
- data/app/assets/stylesheets/{publish_my_data.css → publish_my_data.scss} +13 -2
- data/app/assets/stylesheets/slick_grid/slick_grid.scss +155 -0
- data/app/assets/stylesheets/slick_grid/slick_grid_default_theme.scss +97 -0
- data/app/controllers/concerns/publish_my_data/data_cube.rb +42 -0
- data/app/controllers/publish_my_data/data_cube/dimensions_controller.rb +58 -0
- data/app/controllers/publish_my_data/data_cube/observations_controller.rb +54 -0
- data/app/controllers/publish_my_data/datasets_controller.rb +0 -11
- data/app/controllers/publish_my_data/example_resources_controller.rb +11 -0
- data/app/controllers/publish_my_data/home_controller.rb +4 -0
- data/app/controllers/publish_my_data/information_resources_controller.rb +0 -13
- data/app/helpers/publish_my_data/application_helper.rb +66 -0
- data/app/helpers/publish_my_data/crumb_helper.rb +61 -0
- data/app/helpers/publish_my_data/datasets_helper.rb +31 -0
- data/app/helpers/publish_my_data/resources_helper.rb +24 -0
- data/app/models/concerns/publish_my_data/cube_results.rb +51 -0
- data/app/models/concerns/publish_my_data/dataset_powers.rb +13 -0
- data/app/models/publish_my_data/data_cube/cube.rb +358 -0
- data/app/models/publish_my_data/data_cube/dimension.rb +58 -0
- data/app/models/publish_my_data/vocabulary.rb +0 -4
- data/app/views/layouts/publish_my_data/application.html.haml +18 -0
- data/app/views/layouts/publish_my_data/error.html.haml +21 -0
- data/app/views/publish_my_data/classes/show.html.haml +28 -0
- data/app/views/publish_my_data/concept_schemes/show.html.haml +79 -0
- data/app/views/publish_my_data/concepts/show.html.haml +28 -0
- data/app/views/publish_my_data/data_cube/_controls.html.haml +19 -0
- data/app/views/publish_my_data/data_cube/_grid.html.haml +37 -0
- data/app/views/publish_my_data/datasets/_example_resources.html.haml +47 -0
- data/app/views/publish_my_data/datasets/_types_table.html.erb +33 -0
- data/app/views/publish_my_data/datasets/index.html.haml +32 -0
- data/app/views/publish_my_data/datasets/show.html.haml +186 -0
- data/app/views/publish_my_data/errors/not_found.html.haml +18 -0
- data/app/views/publish_my_data/errors/response_too_large.html.haml +16 -0
- data/app/views/publish_my_data/errors/timeout.html.haml +16 -0
- data/app/views/publish_my_data/errors/uncaught.html.haml +16 -0
- data/app/views/publish_my_data/example_resources/index.js.erb +1 -0
- data/app/views/publish_my_data/home/accessibility.html.haml +1 -0
- data/app/views/publish_my_data/home/docs.html.haml +1 -0
- data/app/views/publish_my_data/home/home.html.haml +5 -0
- data/app/views/publish_my_data/home/privacy.html.haml +1 -0
- data/app/views/publish_my_data/ontologies/show.html.haml +100 -0
- data/app/views/publish_my_data/properties/show.html.haml +28 -0
- data/app/views/publish_my_data/resources/_resource_data.html.haml +16 -0
- data/app/views/publish_my_data/resources/_sparql_section.html.haml +22 -0
- data/app/views/publish_my_data/resources/index.html.haml +37 -0
- data/app/views/publish_my_data/resources/show.html.haml +36 -0
- data/app/views/publish_my_data/shared/_browser_warning.html.haml +4 -0
- data/app/views/publish_my_data/shared/_deprecation_notice.html.haml +8 -0
- data/app/views/publish_my_data/shared/_footer.html.haml +11 -0
- data/app/views/publish_my_data/shared/_google_analytics.html.haml +11 -0
- data/app/views/publish_my_data/shared/_logo.html.haml +1 -0
- data/app/views/publish_my_data/shared/_meta_title.html.haml +2 -0
- data/app/views/publish_my_data/sparql/_form.html.haml +28 -0
- data/app/views/publish_my_data/sparql/_formats_dropdown.html.haml +11 -0
- data/app/views/publish_my_data/sparql/endpoint.html.haml +125 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_ask.html.haml +7 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_construct.html.haml +7 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_describe.html.haml +1 -0
- data/app/views/publish_my_data/sparql/formats_dropdowns/_select.html.haml +9 -0
- data/app/views/publish_my_data/themes/index.html.haml +30 -0
- data/app/views/publish_my_data/themes/show.html.haml +43 -0
- data/config/routes.rb +20 -5
- data/lib/publish_my_data/version.rb +1 -1
- data/lib/publish_my_data.rb +7 -12
- data/spec/controllers/publish_my_data/datasets_controller_spec.rb +0 -75
- data/spec/controllers/publish_my_data/information_resources_controller_spec.rb +2 -11
- data/spec/dummy/config/environments/development.rb +0 -4
- data/spec/dummy/config/environments/test.rb +0 -4
- data/spec/dummy/log/test.log +62962 -0
- data/spec/dummy/tmp/cache/sass/e509ccd4d793d2c162d70125e9f3656b6c28f357/(__TEMPLATE__)c +0 -0
- data/spec/features/running_a_sparql_query_spec.rb +1 -1
- data/spec/features/uri_dereferencing_spec.rb +1 -1
- metadata +200 -58
- data/app/controllers/concerns/publish_my_data/data_download.rb +0 -22
- data/app/controllers/publish_my_data/vocabularies_controller.rb +0 -18
- data/app/views/layouts/publish_my_data/application.html.erb +0 -13
- data/app/views/layouts/publish_my_data/error.html.erb +0 -13
- data/app/views/publish_my_data/classes/show.html.erb +0 -3
- data/app/views/publish_my_data/concept_schemes/_concepts.html.erb +0 -18
- data/app/views/publish_my_data/concept_schemes/show.html.erb +0 -11
- data/app/views/publish_my_data/concepts/show.html.erb +0 -3
- data/app/views/publish_my_data/datasets/index.html.erb +0 -20
- data/app/views/publish_my_data/datasets/show.html.erb +0 -18
- data/app/views/publish_my_data/errors/not_found.html.erb +0 -1
- data/app/views/publish_my_data/errors/response_too_large.html.erb +0 -1
- data/app/views/publish_my_data/errors/timeout.html.erb +0 -1
- data/app/views/publish_my_data/errors/uncaught.html.erb +0 -6
- data/app/views/publish_my_data/ontologies/show.html.erb +0 -17
- data/app/views/publish_my_data/properties/show.html.erb +0 -3
- data/app/views/publish_my_data/resources/_predicates_table.html.erb +0 -30
- data/app/views/publish_my_data/resources/_predicates_table_head.html.erb +0 -6
- data/app/views/publish_my_data/resources/_resource_formats.html.erb +0 -4
- data/app/views/publish_my_data/resources/_summaries.html.erb +0 -18
- data/app/views/publish_my_data/resources/_uri_and_label.html.erb +0 -3
- data/app/views/publish_my_data/resources/index.html.erb +0 -40
- data/app/views/publish_my_data/resources/show.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_ask_formats.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_construct_formats.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_describe_formats.html.erb +0 -1
- data/app/views/publish_my_data/sparql/_error_message.html.erb +0 -3
- data/app/views/publish_my_data/sparql/_form.html.erb +0 -4
- data/app/views/publish_my_data/sparql/_formats.html.erb +0 -6
- data/app/views/publish_my_data/sparql/_pagination.html.erb +0 -6
- data/app/views/publish_my_data/sparql/_results.html.erb +0 -5
- data/app/views/publish_my_data/sparql/_results_data.html.erb +0 -4
- data/app/views/publish_my_data/sparql/_select_formats.html.erb +0 -3
- data/app/views/publish_my_data/sparql/endpoint.html.erb +0 -10
- data/app/views/publish_my_data/themes/index.html.erb +0 -13
- data/app/views/publish_my_data/themes/show.html.erb +0 -15
- data/config/initializers/20_s3_setup.rb +0 -4
- data/spec/controllers/publish_my_data/vocabularies_controller_spec.rb +0 -14
- data/spec/support/data_download.rb +0 -60
@@ -0,0 +1,77 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
function CubeDimension(uri, label, urlBase) {
|
4
|
+
|
5
|
+
// private vars
|
6
|
+
//////////////////
|
7
|
+
|
8
|
+
var size = null
|
9
|
+
, values = null // will contain an array of objects with uri and label keys
|
10
|
+
, onSizeReady = new Slick.Event()
|
11
|
+
, onValuesReady = new Slick.Event()
|
12
|
+
, onAjaxError = new Slick.Event()
|
13
|
+
;
|
14
|
+
|
15
|
+
// private functions.
|
16
|
+
//////////////////
|
17
|
+
|
18
|
+
// memoized lookup of the size of this dimension.
|
19
|
+
function getSizeAsync() {
|
20
|
+
if (!size) {
|
21
|
+
$.ajax({
|
22
|
+
url: urlBase + "/dimension_size.json?dimension=" + encodeURIComponent(uri),
|
23
|
+
success: function(responseData, _, _) {
|
24
|
+
size = responseData['size'];
|
25
|
+
onSizeReady.notify({size: size});
|
26
|
+
},
|
27
|
+
error: function( jqXHR, _, _ ) {
|
28
|
+
onAjaxError.notify({status: jqXHR.status});
|
29
|
+
}
|
30
|
+
});
|
31
|
+
} else {
|
32
|
+
onSizeReady.notify({size: size});
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
// memoized lookup of all the values in this dimension
|
37
|
+
function getValuesAsync() {
|
38
|
+
if (!values) {
|
39
|
+
$.ajax({
|
40
|
+
url: urlBase + "/dimension_values.json?dimension=" + encodeURIComponent(uri),
|
41
|
+
success: function(responseData, _, _) {
|
42
|
+
values = responseData;
|
43
|
+
onValuesReady.notify({values: values});
|
44
|
+
},
|
45
|
+
error: function( jqXHR, _, _ ) {
|
46
|
+
onAjaxError.notify({status: jqXHR.status});
|
47
|
+
}
|
48
|
+
});
|
49
|
+
} else {
|
50
|
+
onValuesReady.notify({values: values});
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
// public api.
|
55
|
+
//////////////////
|
56
|
+
|
57
|
+
return {
|
58
|
+
|
59
|
+
//properties
|
60
|
+
"label": label
|
61
|
+
, "uri": uri
|
62
|
+
|
63
|
+
// methods
|
64
|
+
, "getSizeAsync": getSizeAsync // raises the onSizeReady event, with the size as the arg.
|
65
|
+
, "getValuesAsync": getValuesAsync // raises the onValuesReady event with the values as the arg.
|
66
|
+
|
67
|
+
// events
|
68
|
+
, "onSizeReady": onSizeReady
|
69
|
+
, "onValuesReady": onValuesReady // contains the new values.
|
70
|
+
, "onAjaxError": onAjaxError
|
71
|
+
};
|
72
|
+
}
|
73
|
+
|
74
|
+
// Swirrl.CubeDimension
|
75
|
+
|
76
|
+
$.extend(true, window, { Swirrl: { CubeDimension: CubeDimension }});
|
77
|
+
})(jQuery);
|
@@ -0,0 +1,87 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
// posisble values needs to be an array of objects which respond to uri and label.
|
4
|
+
function CubeDimensionDropdown(possibleValues, elementId) {
|
5
|
+
|
6
|
+
// private vars
|
7
|
+
///////////////
|
8
|
+
var jQueryElement = null
|
9
|
+
, currentValue = null
|
10
|
+
;
|
11
|
+
|
12
|
+
init();
|
13
|
+
|
14
|
+
// private funcs
|
15
|
+
/////////////////
|
16
|
+
|
17
|
+
function init() {
|
18
|
+
// create the element
|
19
|
+
jQueryElement = $("<select></select>");
|
20
|
+
jQueryElement.addClass("dimension-dropdown");
|
21
|
+
jQueryElement.attr('id', elementId);
|
22
|
+
|
23
|
+
// add all the options
|
24
|
+
populateOptions(possibleValues);
|
25
|
+
}
|
26
|
+
|
27
|
+
function disable() {
|
28
|
+
jQueryElement.attr("disabled", "disabled");
|
29
|
+
return jQueryElement;
|
30
|
+
}
|
31
|
+
|
32
|
+
function enable() {
|
33
|
+
jQueryElement.removeAttr("disabled");
|
34
|
+
return jQueryElement;
|
35
|
+
}
|
36
|
+
|
37
|
+
function populateOptions(possibleValues) {
|
38
|
+
empty();
|
39
|
+
$.each(possibleValues, function (i, possVal) {
|
40
|
+
var option = $("<option></option>");
|
41
|
+
option.attr("value", possVal.uri);
|
42
|
+
option.append(possVal.label || possVal.uri);
|
43
|
+
jQueryElement.append(option);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
function setValue(value) {
|
48
|
+
jQueryElement.val(value);
|
49
|
+
return jQueryElement;
|
50
|
+
}
|
51
|
+
|
52
|
+
function getValue() {
|
53
|
+
return jQueryElement.val();
|
54
|
+
}
|
55
|
+
|
56
|
+
function getSelectedLabel() {
|
57
|
+
return jQueryElement.find(":selected").text();
|
58
|
+
}
|
59
|
+
|
60
|
+
function empty() {
|
61
|
+
jQueryElement.empty();
|
62
|
+
}
|
63
|
+
|
64
|
+
// public api.
|
65
|
+
//////////////////
|
66
|
+
return {
|
67
|
+
// properties
|
68
|
+
"elementId": elementId
|
69
|
+
, "jQueryElement": jQueryElement
|
70
|
+
|
71
|
+
// methods
|
72
|
+
, "setValue": setValue
|
73
|
+
, "getValue": getValue
|
74
|
+
, "getLabel": getSelectedLabel
|
75
|
+
, "empty": empty
|
76
|
+
, "populateOptions": populateOptions
|
77
|
+
, "disable": disable
|
78
|
+
, "enable": enable
|
79
|
+
// events
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
// Swirrl.DimensionDropdown
|
86
|
+
$.extend(true, window, { Swirrl: { CubeDimensionDropdown: CubeDimensionDropdown }});
|
87
|
+
})(jQuery);
|
@@ -0,0 +1,58 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
// posisble values needs to be an array of objects which respond to uri and label.
|
4
|
+
function CubeDimensionLabel(possibleValues, elementId) {
|
5
|
+
|
6
|
+
// private vars
|
7
|
+
///////////////
|
8
|
+
var jQueryElement = null
|
9
|
+
, uri = null
|
10
|
+
;
|
11
|
+
|
12
|
+
init();
|
13
|
+
|
14
|
+
function init() {
|
15
|
+
// create the element
|
16
|
+
jQueryElement = $("<label></label>");
|
17
|
+
jQueryElement.attr('id', elementId);
|
18
|
+
}
|
19
|
+
|
20
|
+
function setValue(value) {
|
21
|
+
|
22
|
+
uri = value;
|
23
|
+
|
24
|
+
var label = null;
|
25
|
+
$.each(possibleValues, function(i, pv) {
|
26
|
+
if (pv.uri == uri) {
|
27
|
+
label = (pv.label || pv.uri);
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
|
32
|
+
jQueryElement.text(label);
|
33
|
+
}
|
34
|
+
|
35
|
+
function getValue() {
|
36
|
+
return uri;
|
37
|
+
}
|
38
|
+
|
39
|
+
function getSelectedLabel() {
|
40
|
+
return jQueryElement.text();
|
41
|
+
}
|
42
|
+
|
43
|
+
// public api.
|
44
|
+
//////////////////
|
45
|
+
return {
|
46
|
+
// properties
|
47
|
+
"elementId": elementId
|
48
|
+
, "jQueryElement": jQueryElement
|
49
|
+
|
50
|
+
// methods
|
51
|
+
, "setValue": setValue
|
52
|
+
, "getValue": getValue
|
53
|
+
, "getLabel": getSelectedLabel
|
54
|
+
}
|
55
|
+
}
|
56
|
+
// Swirrl.DimensionLabel
|
57
|
+
$.extend(true, window, { Swirrl: { CubeDimensionLabel: CubeDimensionLabel }});
|
58
|
+
})(jQuery);
|
@@ -0,0 +1,336 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
// object to marshall communication between the grid and all the dimension controls
|
4
|
+
function CubeDimensionsControls(cubeGrid, containerSelector) {
|
5
|
+
|
6
|
+
// private vars
|
7
|
+
var rowsDimensionDropdown = null
|
8
|
+
, columnsDimenesionDropdown = null
|
9
|
+
, lockedDimensionValuesDropdowns = []
|
10
|
+
, lockedDimensionLabelControls = []
|
11
|
+
, initialized = false
|
12
|
+
;
|
13
|
+
|
14
|
+
// events
|
15
|
+
var onReady = new Slick.Event();
|
16
|
+
var onBusy = new Slick.Event();
|
17
|
+
var onInitialized = new Slick.Event();
|
18
|
+
|
19
|
+
// private functions
|
20
|
+
/////////////////////
|
21
|
+
|
22
|
+
function init() {
|
23
|
+
|
24
|
+
onBusy.notify();
|
25
|
+
|
26
|
+
// make sure we've got all the dimensions we need. We assume that the cube has retrieved it's dimensions before starting here.
|
27
|
+
if (!checkDimensions() ){
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
|
31
|
+
// drop downs for the row and col dimensions.
|
32
|
+
createRowsDimensionDropdown();
|
33
|
+
createColumnsDimensionDropdown();
|
34
|
+
createLockedDimensionsDropdownsAnync();
|
35
|
+
}
|
36
|
+
|
37
|
+
function createRowsDimensionDropdown() {
|
38
|
+
rowsDimensionDropdown = new Swirrl.CubeDimensionDropdown(cubeGrid.getCubeDimensions(), 'rows-dimension-dropdown');
|
39
|
+
$('#rows-dimension-container').append(rowsDimensionDropdown.jQueryElement);
|
40
|
+
rowsDimensionDropdown.setValue(cubeGrid.getRowsDimension().uri);
|
41
|
+
rowsDimensionDropdown.disable(); // create as disabled
|
42
|
+
wireUpDimensionDropDownChanged(rowsDimensionDropdown);
|
43
|
+
}
|
44
|
+
|
45
|
+
function createColumnsDimensionDropdown() {
|
46
|
+
columnsDimensionDropdown = new Swirrl.CubeDimensionDropdown(cubeGrid.getCubeDimensions(), 'columns-dimension-dropdown');
|
47
|
+
$('#columns-dimension-container').append(columnsDimensionDropdown.jQueryElement);
|
48
|
+
columnsDimensionDropdown.setValue(cubeGrid.getColumnsDimension().uri);
|
49
|
+
columnsDimensionDropdown.disable(); // create as disabled
|
50
|
+
wireUpDimensionDropDownChanged(columnsDimensionDropdown);
|
51
|
+
}
|
52
|
+
|
53
|
+
function createLockedDimensionsDropdownsAnync() {
|
54
|
+
// make drop downs for the locked dimensions
|
55
|
+
var lockedDimensionsSelector = containerSelector + " .locked-dimensions";
|
56
|
+
var dimensionsReady = 0;
|
57
|
+
|
58
|
+
var lockedDimObjects = cubeGrid.getLockedDimensionObjects();
|
59
|
+
|
60
|
+
if (lockedDimObjects.length == 0) {
|
61
|
+
// nothing to do.
|
62
|
+
onReady.notify();
|
63
|
+
if(!initialized) {onInitialized.notify();}
|
64
|
+
} else {
|
65
|
+
$(lockedDimensionsSelector).empty(); // clear out the div, ready for action.
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
$.each(lockedDimObjects, function(i, lockedDim) {
|
70
|
+
|
71
|
+
var valuesReadyHandler = function (e, args) {
|
72
|
+
// unsubscribe: we only want to do this setup once
|
73
|
+
lockedDim.onValuesReady.unsubscribe(valuesReadyHandler);
|
74
|
+
|
75
|
+
// 1. the label
|
76
|
+
////////////////////
|
77
|
+
var field = $('<div class="field"></div>');
|
78
|
+
$(lockedDimensionsSelector).append(field);
|
79
|
+
|
80
|
+
// 1. the label for this dimension
|
81
|
+
//////////////////
|
82
|
+
var cubeDimLabel = new Swirrl.CubeDimensionLabel(cubeGrid.getCubeDimensions(), 'locked-dimension-label' + i.toString() + '-label');
|
83
|
+
cubeDimLabel.setValue(lockedDim.uri);
|
84
|
+
field.append(cubeDimLabel.jQueryElement);
|
85
|
+
lockedDimensionLabelControls.push(cubeDimLabel);
|
86
|
+
|
87
|
+
// 2. the values for this dimension
|
88
|
+
////////////////////
|
89
|
+
var valuesDropdown = new Swirrl.CubeDimensionDropdown(args.values, 'locked-dimension-dropdown' + i.toString() + '-value');
|
90
|
+
var valuesPicker = $('<div class="locked-dimension picker"></div>');
|
91
|
+
valuesPicker.append(valuesDropdown.jQueryElement);
|
92
|
+
field.append(valuesPicker);
|
93
|
+
valuesDropdown.setValue(cubeGrid.getLockedDimensionValue(lockedDim.uri));
|
94
|
+
valuesDropdown.disable(); // create as disbaled
|
95
|
+
|
96
|
+
// add it to our collection
|
97
|
+
lockedDimensionValuesDropdowns.push(valuesDropdown);
|
98
|
+
|
99
|
+
// use the special locked dimension wirer-upper for the locked dims.
|
100
|
+
wireUpLockedDimensionValuesChanged(valuesDropdown);
|
101
|
+
|
102
|
+
dimensionsReady++;
|
103
|
+
|
104
|
+
// Have we finished? we've got all of em.
|
105
|
+
if (dimensionsReady == cubeGrid.getLockedDimensionObjects().length) {
|
106
|
+
onReady.notify();
|
107
|
+
if(!initialized) {onInitialized.notify();}
|
108
|
+
}
|
109
|
+
|
110
|
+
} // end handler func
|
111
|
+
|
112
|
+
lockedDim.onValuesReady.subscribe(valuesReadyHandler);
|
113
|
+
lockedDim.getValuesAsync();
|
114
|
+
|
115
|
+
});
|
116
|
+
}
|
117
|
+
|
118
|
+
function disable() {
|
119
|
+
$.each(getAllDropdowns(), function(i, dd) {
|
120
|
+
dd.disable();
|
121
|
+
});
|
122
|
+
}
|
123
|
+
|
124
|
+
function enable() {
|
125
|
+
$.each(getAllDropdowns(), function(i, dd) {
|
126
|
+
dd.enable();
|
127
|
+
});
|
128
|
+
}
|
129
|
+
|
130
|
+
function getRowsDimension() {
|
131
|
+
var rowsDimensionUri = rowsDimensionDropdown.getValue();
|
132
|
+
return findCubeDimensionWithUri(rowsDimensionUri);
|
133
|
+
}
|
134
|
+
|
135
|
+
function getColumnsDimension() {
|
136
|
+
var columnsDimensionUri = columnsDimensionDropdown.getValue();
|
137
|
+
return findCubeDimensionWithUri(columnsDimensionUri);
|
138
|
+
}
|
139
|
+
|
140
|
+
function getLockedDimensionUris() {
|
141
|
+
return $.map(lockedDimensionLabelControls, function(labControl, i) {
|
142
|
+
return labControl.getValue();
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
146
|
+
function getLockedDimensionValues() {
|
147
|
+
return $.map( lockedDimensionValuesDropdowns, function(dd, i) {
|
148
|
+
return dd.getValue();
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
function getLockedDimensionValueLabels() {
|
153
|
+
return $.map( lockedDimensionValuesDropdowns, function(dd, i) {
|
154
|
+
return dd.getLabel();
|
155
|
+
});
|
156
|
+
}
|
157
|
+
|
158
|
+
function checkDimensions() {
|
159
|
+
|
160
|
+
if (!cubeGrid.getCubeDimensions()) {
|
161
|
+
alert("You can't initialise the cube dimension controls unless the cube's dimensions have been initialised");
|
162
|
+
return false;
|
163
|
+
}
|
164
|
+
|
165
|
+
if (!cubeGrid.getRowsDimension) {
|
166
|
+
alert("You can't initialise the cube dimension controls unless the cube's rowsDimensions has been set");
|
167
|
+
return false;
|
168
|
+
}
|
169
|
+
|
170
|
+
if (!cubeGrid.getColumnsDimension) {
|
171
|
+
alert("You can't initialise the cube dimension controls unless the cube's columnsDimensions has been set");
|
172
|
+
return false;
|
173
|
+
}
|
174
|
+
|
175
|
+
if(!cubeGrid.checkLockedDimensions()) {
|
176
|
+
alert('missing locked dimensions');
|
177
|
+
return false;
|
178
|
+
}
|
179
|
+
|
180
|
+
return true;
|
181
|
+
}
|
182
|
+
|
183
|
+
function getAllDropdowns() {
|
184
|
+
var dropdowns = [];
|
185
|
+
if(rowsDimensionDropdown){ dropdowns = dropdowns.concat(rowsDimensionDropdown); }
|
186
|
+
if(rowsDimensionDropdown){ dropdowns = dropdowns.concat(columnsDimensionDropdown); }
|
187
|
+
dropdowns = dropdowns.concat(lockedDimensionValuesDropdowns);
|
188
|
+
return dropdowns;
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
function findControlWithValue(value, excludeControlWithId) {
|
193
|
+
|
194
|
+
var allDropDowns = getAllDropdowns();
|
195
|
+
var allControls = allDropDowns.concat(lockedDimensionLabelControls);
|
196
|
+
var theControl = null;
|
197
|
+
|
198
|
+
$.each(allControls, function(i, con) {
|
199
|
+
|
200
|
+
if(con.getValue() == value && con.elementId != excludeControlWithId) {
|
201
|
+
theControl = con;
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
});
|
205
|
+
return theControl;
|
206
|
+
}
|
207
|
+
|
208
|
+
function findUnusedDimensionUri() {
|
209
|
+
var allDimensionControls = getAllDropdowns();
|
210
|
+
var allDimensions = cubeGrid.getCubeDimensions();
|
211
|
+
|
212
|
+
var allDimensionUris = $.map(allDimensions, function(dim, i) {
|
213
|
+
return dim.uri;
|
214
|
+
});
|
215
|
+
|
216
|
+
var usedDimensionUris = [];
|
217
|
+
var unusedDimension = null;
|
218
|
+
|
219
|
+
$.each(getAllDropdowns(), function(i, dd) {
|
220
|
+
usedDimensionUris.push(dd.getValue());
|
221
|
+
});
|
222
|
+
|
223
|
+
$.each(lockedDimensionLabelControls, function(i, labCon) {
|
224
|
+
usedDimensionUris.push(labCon.getValue());
|
225
|
+
});
|
226
|
+
|
227
|
+
$.grep(allDimensionUris, function(el) {
|
228
|
+
if (jQuery.inArray(el, usedDimensionUris) == -1) unusedDimension = el;
|
229
|
+
});
|
230
|
+
|
231
|
+
// there should be at most one unused dimension
|
232
|
+
return unusedDimension;
|
233
|
+
}
|
234
|
+
|
235
|
+
function findCubeDimensionWithUri(uri) {
|
236
|
+
var dim = null;
|
237
|
+
|
238
|
+
$.each( cubeGrid.getCubeDimensions(), function (i, cubeDim) {
|
239
|
+
if(uri == cubeDim.uri) {
|
240
|
+
dim = cubeDim;
|
241
|
+
return false;
|
242
|
+
}
|
243
|
+
});
|
244
|
+
|
245
|
+
return dim;
|
246
|
+
}
|
247
|
+
|
248
|
+
function wireUpDimensionDropDownChanged(dropdown) {
|
249
|
+
|
250
|
+
$(dropdown.jQueryElement).change(function(e) {
|
251
|
+
|
252
|
+
onBusy.notify();
|
253
|
+
|
254
|
+
var newValue = $(this).val(); // what's the new value of this dropdown?
|
255
|
+
var prevControl = findControlWithValue(newValue, $(this).attr('id')); // now find where the new value was used (excluding this control)
|
256
|
+
var unusedDimensionUri = findUnusedDimensionUri(); // what dimension uri is now unused?
|
257
|
+
|
258
|
+
// Update the other controls accordingly...
|
259
|
+
|
260
|
+
if(prevControl) {
|
261
|
+
var previouslyLocked = ($.inArray( prevControl.getValue(), getLockedDimensionUris()) >= 0);
|
262
|
+
|
263
|
+
// was it previously used as a locked dim?
|
264
|
+
if (previouslyLocked) {
|
265
|
+
prevControl.setValue(unusedDimensionUri);
|
266
|
+
updateLockedDimensionValuesDropDown(prevControl); // this will raise notify when it's ready
|
267
|
+
} else {
|
268
|
+
prevControl.setValue(unusedDimensionUri);
|
269
|
+
onReady.notify();
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
});
|
274
|
+
}
|
275
|
+
|
276
|
+
|
277
|
+
function updateLockedDimensionValuesDropDown(labelControl) {
|
278
|
+
|
279
|
+
// find the associated values drop down
|
280
|
+
var valuesDropdownJQ = labelControl.jQueryElement;
|
281
|
+
var valuesDropdownId = valuesDropdownJQ.closest('div.field').find('select').attr('id');
|
282
|
+
|
283
|
+
valuesDropDownControl = null;
|
284
|
+
$.each( lockedDimensionValuesDropdowns, function(i, valuedd) {
|
285
|
+
if (valuedd.elementId == valuesDropdownId) {
|
286
|
+
valuesDropDownControl = valuedd;
|
287
|
+
}
|
288
|
+
});
|
289
|
+
|
290
|
+
var lockedDimensionUri = labelControl.getValue(); // the new value.
|
291
|
+
|
292
|
+
// find the dimension object with the uri
|
293
|
+
var lockedDimension = findCubeDimensionWithUri(lockedDimensionUri);
|
294
|
+
|
295
|
+
var onValuesReadyHandler = function (e, args) {
|
296
|
+
valuesDropDownControl.populateOptions(args.values);
|
297
|
+
onReady.notify();
|
298
|
+
lockedDimension.onValuesReady.unsubscribe(onValuesReadyHandler); // only respond once.
|
299
|
+
}
|
300
|
+
|
301
|
+
// update the options when the values arrive.
|
302
|
+
lockedDimension.onValuesReady.subscribe(onValuesReadyHandler);
|
303
|
+
lockedDimension.getValuesAsync();
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
|
308
|
+
function wireUpLockedDimensionValuesChanged(valuesDropdown) {
|
309
|
+
$(valuesDropdown.jQueryElement).change(function(e) {
|
310
|
+
onBusy.notify();
|
311
|
+
onReady.notify();
|
312
|
+
});
|
313
|
+
}
|
314
|
+
|
315
|
+
return {
|
316
|
+
|
317
|
+
// methods
|
318
|
+
"init": init // perform initialization
|
319
|
+
, "getRowsDimension": getRowsDimension // returns a cube dimension object
|
320
|
+
, "getColumnsDimension": getColumnsDimension // returns a cube dimension object
|
321
|
+
, "getLockedDimensionUris": getLockedDimensionUris
|
322
|
+
, "getLockedDimensionValues": getLockedDimensionValues
|
323
|
+
, "getLockedDimensionValueLabels": getLockedDimensionValueLabels
|
324
|
+
, "enable": enable
|
325
|
+
, "disable": disable
|
326
|
+
|
327
|
+
// events
|
328
|
+
, "onBusy": onBusy
|
329
|
+
, "onReady": onReady // contains the new values.
|
330
|
+
, "onInitialized": onInitialized
|
331
|
+
};
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
$.extend(true, window, { Swirrl: { CubeDimensionsControls: CubeDimensionsControls }});
|
336
|
+
})(jQuery);
|