Skip to content

Commit 3d3bae2

Browse files
committed
[Overlay] add suppression option to overlay dialog
1 parent 5be103e commit 3d3bae2

File tree

4 files changed

+53
-18
lines changed

4 files changed

+53
-18
lines changed

src/api/overlays/Overlay.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Overlay extends EventEmitter {
1919
element,
2020
onDestroy,
2121
onDismiss,
22+
showSuppressOption = false,
23+
suppressionText = "Don't ask again",
2224
size
2325
} = {}) {
2426
super();
@@ -38,6 +40,8 @@ class Overlay extends EventEmitter {
3840
dismiss: this.notifyAndDismiss.bind(this),
3941
element,
4042
buttons,
43+
showSuppressOption,
44+
suppressionText,
4145
dismissible: this.dismissible
4246
},
4347
template: '<overlay-component></overlay-component>'

src/api/overlays/components/OverlayComponent.vue

+28-16
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,27 @@
3535
class="c-overlay__contents js-notebook-snapshot-item-wrapper"
3636
tabindex="0"
3737
></div>
38-
<div v-if="buttons" class="c-overlay__button-bar">
39-
<button
40-
v-for="(button, index) in buttons"
41-
ref="buttons"
42-
:key="index"
43-
class="c-button js-overlay__button"
44-
tabindex="0"
45-
:class="{ 'c-button--major': focusIndex === index }"
46-
@focus="focusIndex = index"
47-
@click="buttonClickHandler(button.callback)"
48-
>
49-
{{ button.label }}
50-
</button>
38+
<div v-if="buttons || showSuppressOption" class="c-overlay__footer">
39+
<div class="c-overlay__suppress-option">
40+
<div v-if="showSuppressOption">
41+
<input v-model="suppress" type="checkbox" class="l-composite-control l-checkbox" />
42+
<label>{{ suppressionText }}</label>
43+
</div>
44+
</div>
45+
<div v-if="buttons" class="c-overlay__button-bar">
46+
<button
47+
v-for="(button, index) in buttons"
48+
ref="buttons"
49+
:key="index"
50+
class="c-button js-overlay__button"
51+
tabindex="0"
52+
:class="{ 'c-button--major': focusIndex === index }"
53+
@focus="focusIndex = index"
54+
@click="buttonClickHandler(button.callback)"
55+
>
56+
{{ button.label }}
57+
</button>
58+
</div>
5159
</div>
5260
</div>
5361
</div>
@@ -56,11 +64,12 @@
5664

5765
<script>
5866
export default {
59-
inject: ['dismiss', 'element', 'buttons', 'dismissible'],
67+
inject: ['dismiss', 'element', 'buttons', 'dismissible', 'showSuppressOption', 'suppressionText'],
6068
emits: ['destroy'],
6169
data() {
6270
return {
63-
focusIndex: -1
71+
focusIndex: -1,
72+
suppress: false
6473
};
6574
},
6675
mounted() {
@@ -78,7 +87,10 @@ export default {
7887
}
7988
},
8089
buttonClickHandler(method) {
81-
method();
90+
let callbackData = {
91+
suppress: this.suppress
92+
};
93+
method(callbackData);
8294
this.$emit('destroy');
8395
},
8496
getElementForFocus() {

src/api/overlays/components/overlay-component.scss

+13
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@
101101
padding-right: $interiorMargin; // fend off scroll bar
102102
}
103103

104+
&__footer {
105+
margin-top: $interiorMargin;
106+
display: flex;
107+
justify-content: space-between;
108+
width: 100%;
109+
}
110+
111+
&__suppress-option {
112+
justify-items: start;
113+
align-self: center;
114+
padding-left: $interiorMargin;
115+
}
116+
104117
&__button-bar {
105118
flex: 0 0 auto;
106119
display: flex;

src/plugins/plot/MctPlot.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,9 @@ export default {
17951795

17961796
showSynchronizeDialog() {
17971797
const isFixedTimespanMode = this.timeContext.isFixed();
1798-
if (!isFixedTimespanMode) {
1798+
const SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY = 'sync-time-conductor-modal-suppression';
1799+
let isSuppressed = localStorage.getItem(SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY);
1800+
if (!isFixedTimespanMode && !isSuppressed) {
17991801
const message = `
18001802
This action will change the Time Conductor to Fixed Timespan mode with this plot view's current time bounds.
18011803
Do you want to continue?
@@ -1806,12 +1808,16 @@ export default {
18061808
iconClass: 'alert',
18071809
size: 'fit',
18081810
message: message,
1811+
showSuppressOption: true,
18091812
buttons: [
18101813
{
18111814
label: 'Ok',
1812-
callback: () => {
1815+
callback: (data) => {
18131816
dialog.dismiss();
18141817
this.synchronizeTimeConductor();
1818+
if (data && data.suppress) {
1819+
localStorage.setItem(SYNC_TIME_CONDUCTOR_SUPPRESSION_KEY, true);
1820+
}
18151821
}
18161822
},
18171823
{

0 commit comments

Comments
 (0)