Commit c4d5822b authored by Eirik Alvær's avatar Eirik Alvær
parents 805029e6 cb537a26
......@@ -57,7 +57,7 @@ var Server = (function ($, _) {
var callback = findCallbackInArguments(payload, fn),
url = prepareUrl(payload);
if (isSameRequest(url)) {
if (isSameRequest(url) && callback !== undefined) {
callback(currentCube);
return;
}
......
......@@ -202,7 +202,7 @@
payload = {},
dimension = {'id': dimensionID},
referenceMember = getSelectedReferenceMember(parentForm),
checkedMembers = $(parentForm).find("input:checkbox:checked").map(function () {
checkedMembers = $(parentForm).find(".levellists input:checkbox:checked").map(function () {
return $(this).val();
}).get();
......@@ -327,6 +327,16 @@
return this;
},
setCheckedFylker = function (form, value, checked) {
var cube = Server.getCurrentCube(),
fylker = _.filter(cube.dimensions[0].members, function (member) {
return member.level === 'Fylker' && value.indexOf(member.id) === 0;
});
_.each(fylker, function (member) {
$(form).find("#Fylker input[value='" + member.id + "']").prop('checked', checked);
});
},
addControlDimension = function (config) {
var container = config.selector,
dimensionID = config.dimensionID,
......@@ -352,13 +362,35 @@
$('.alphabet .current').removeClass('current');
$(this).addClass('current');
})
.on('change', '.spiderwidget input[type="checkbox"]', function (event) {
.on('change', '.spiderwidget .levellists input[type="checkbox"]', function (event) {
var element = event.currentTarget,
form = $(element).parents('form');
Messagebus.sendMessage('member-toggle', event);
onControlDimensionChanged(form, dimensionID);
})
.on('change', '.includeFylkCheckbox', function (event) {
var element = event.currentTarget,
form = $(element).parents('form');
if (element.checked !== true) {
$(form).find("#Fylker input:checkbox:checked").each(function () {
$(this).prop('checked', false);
});
} else {
$(form).find("#Kommuner input:checkbox:checked").each(function () {
setCheckedFylker(form, $(this).val(), true);
});
}
onControlDimensionChanged(form, dimensionID);
});
Messagebus.add(function (event) {
if (event.name === "member-toggle") {
var element = event.data.currentTarget,
form = $(element).parents('form');
setCheckedFylker(form, $(element).val(), $(".includeFylkCheckbox").prop("checked") && element.checked);
}
});
if (allowsChangingReferenceMember(config.options)) {
containerNode.on('change', '.spiderwidget select[name="reference"]', function (event) {
var selectedOption = event.currentTarget,
......
......@@ -33,6 +33,9 @@
<a>&#216;</a>
<a class="last">&#xC5;</a>
</div>
<div><ul><li class="search-filter-item checkbox-item clearfix">
<label>Inkluder fylkestall for kommunene du har valgt<input class="includeFylkCheckbox" type="checkbox"></label>
</ul></li></div>
</div>
{{/if}}
{{#if useReferenceList}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment