Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/GADS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3499,8 +3499,8 @@ prefix '/:layout_name' => sub {
my $params = params;
my $columns = ref param('column') ? param('column') : [ param('column') // () ]; # Ensure array
$view->columns($columns);
$view->global(param('global') ? 1 : 0);
$view->is_admin(param('is_admin') ? 1 : 0);
$view->global(param('viewType') == 2 ? 1 : 0);
$view->is_admin(param('viewType') == 3 ? 1 : 0);
$view->group_id(param 'group_id');
$view->name (param 'name');
$view->filter->as_json(param 'filter');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { initializeComponent } from 'component'
import RadioRevealComponent from './lib/component'

export default (scope) => initializeComponent(scope, '.radio-reveal', RadioRevealComponent)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Component } from "component";
import { hideElement, showElement } from "util/common";

export default class RadioRevealComponent extends Component {
private el: JQuery<HTMLElement>;

constructor(element: HTMLElement) {
super(element);
this.el = $(this.element);
this.init();
}

private init() {
const target = this.el.data("radio-target");
const value = this.el.data("radio-value");

if (!target || !value) {
console.error("RadioRevealComponent: Missing data-radio-target or data-radio-value attribute.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this picked up by our /scripterror frontend error catching endpoint?

return;
}

const radioButtons = $(`input[name="${target}"]`);

radioButtons.on("change", () => {
this.toggleVisibility(radioButtons, value);
});

// Initial check
this.toggleVisibility(radioButtons, value);
}

toggleVisibility(radioButtons: JQuery<HTMLElement>, value: string) {
if (radioButtons.filter(":checked").val() == value) {
showElement(this.el);
} else {
hideElement(this.el);
}
}
}
2 changes: 2 additions & 0 deletions src/frontend/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import TextareaComponent from 'components/form-group/textarea';
import TimelineComponent from 'components/timeline';
import TippyComponent from 'components/timeline/tippy';
import TreeComponent from 'components/form-group/tree';
import RadioRevealComponent from 'components/form-group/radio-group/radio-reveal';
import UserModalComponent from 'components/modal/modals/user';
import ValueLookupComponent from 'components/form-group/value-lookup';
import MarkdownComponent from "components/markdown";
Expand Down Expand Up @@ -69,6 +70,7 @@ registerComponent(MultipleSelectComponent);
registerComponent(OrderableSortableComponent);
registerComponent(PopoverComponent);
registerComponent(RadioGroupComponent);
registerComponent(RadioRevealComponent);
registerComponent(RecordPopupComponent);
registerComponent(SelectComponent);
registerComponent(SelectWidgetComponent);
Expand Down
39 changes: 16 additions & 23 deletions views/view.tt
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,21 @@
</div>
</div>
<div class="row">
<div class="col-lg-3">
[%
INCLUDE fields/sub/checkbox.tt
id = "global"
name = "global"
label = "Shared view"
value = 1
checked = view_edit.global ? 1 : 0
input_class = "mb-lg-0 checkbox--reveal";
%]
</div>

<div class="col-lg-9">
[%
INCLUDE fields/sub/checkbox.tt
id = "is_admin"
name = "is_admin"
label = "Administration view (only visible to table administrators)"
value = 1
checked = view_edit.is_admin ? 1 : 0
input_class = "mb-lg-0";
%]
<div class="col-12 my-3">
<div class="d-lg-flex flex-row justify-content-between d-md-block radio-group radio-group-toggle">
<div class="ml-md-2 ml-sm-3 radio-group__option">
<input class="radio-group__input" type="radio" id="viewType1" name="viewType" value="1" [% UNLESS view_edit.global || view_edit.is_admin %]checked[% END %] />
<label for="viewType1" class="radio-group__label">Personal View</label>
</div>
<div class="ml-md-2 ml-sm-3 radio-group__option">
<input class="radio-group__input" type="radio" id="viewType2" name="viewType" value="2" [% IF view_edit.global && !view_edit.is_admin %]checked[% END %] />
<label for="viewType2" class="radio-group__label">Shared View</label>
</div>
<div class="ml-md-2 ml-sm-3 radio-group__option">
<input class="radio-group__input" type="radio" id="viewType3" name="viewType" value="3" [% IF view_edit.is_admin %]checked[% END %] />
<label for="viewType3" class="radio-group__label">Admin View (only visible to table administrators)</label>
</div>
</div>
</div>
</div>
</div>
Expand All @@ -79,7 +72,7 @@
<div class="row">
<div class="col">

<div class="checkbox-reveal" id="global-reveal">
<div class="radio-reveal" id="radio-reveal" data-radio-target="viewType" data-radio-value="2">
[%
group_id_items = layout.user_can("layout") ? [{id="", name="<All users>"}] : [];

Expand Down
Loading