Skip to content

Commit 7b6127e

Browse files
authored
Merge pull request #1 from jmchilton/feature/convert-collections-to-vue
Pull John's updates into my branch
2 parents d9c6bb8 + 09c64d5 commit 7b6127e

7 files changed

Lines changed: 77 additions & 236 deletions

File tree

client/src/components/Collections/ListCollectionCreator.vue

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
</div>
6464
<collection-creator
6565
:oncancel="oncancel"
66-
@hide-original-toggle="hideOriginalsToggle"
66+
:hideSourceItems="hideSourceItems"
67+
@onUpdateHideSourceItems="onUpdateHideSourceItems"
6768
@clicked-create="clickedCreate"
6869
@remove-extensions-toggle="removeExtensionsToggle"
6970
:creationFn="creationFn"
@@ -197,7 +198,7 @@
197198
</template>
198199

199200
<script>
200-
import CollectionCreator from "./common/CollectionCreator";
201+
import mixin from "./common/mixin";
201202
import DatasetCollectionElementView from "./ListDatasetCollectionElementView";
202203
import _l from "utils/localization";
203204
import STATES from "mvc/dataset/states";
@@ -208,12 +209,13 @@ import draggable from "vuedraggable";
208209
209210
Vue.use(BootstrapVue);
210211
export default {
212+
mixins: [mixin],
211213
created() {
212214
this._instanceSetUp();
213215
this._elementsSetUp();
214216
this.saveOriginalNames();
215217
},
216-
components: { CollectionCreator, DatasetCollectionElementView, draggable },
218+
components: { DatasetCollectionElementView, draggable },
217219
data: function () {
218220
return {
219221
state: "build", //error
@@ -236,28 +238,6 @@ export default {
236238
};
237239
},
238240
props: {
239-
initialElements: {
240-
required: true,
241-
type: Array,
242-
},
243-
creationFn: {
244-
type: Function,
245-
required: true,
246-
},
247-
/** fn to call when the cancel button is clicked (scoped to this) - if falsy, no btn is displayed */
248-
oncancel: {
249-
type: Function,
250-
required: true,
251-
},
252-
oncreate: {
253-
type: Function,
254-
required: true,
255-
},
256-
defaultHideSourceItems: {
257-
type: Boolean,
258-
required: false,
259-
default: false,
260-
},
261241
/** distance from list edge to begin autoscrolling list */
262242
autoscrollDist: {
263243
type: Number,
@@ -397,14 +377,11 @@ export default {
397377
clickClearAll: function () {
398378
this.selectedDatasetElems = [];
399379
},
400-
hideOriginalsToggle: function () {
401-
this.defaultHideSourceItems = !this.defaultHideSourceItems;
402-
},
403380
clickedCreate: function (collectionName) {
404381
this.checkForDuplicates();
405382
if (this.state !== "error") {
406-
this.$emit("clicked-create", this.workingElements, this.collectionName, this.defaultHideSourceItems);
407-
return this.creationFn(this.workingElements, collectionName, this.defaultHideSourceItems)
383+
this.$emit("clicked-create", this.workingElements, this.collectionName, this.hideSourceItems);
384+
return this.creationFn(this.workingElements, collectionName, this.hideSourceItems)
408385
.done(this.oncreate)
409386
.fail(() => {
410387
this.state = "error";

client/src/components/Collections/PairCollectionCreator.vue

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
</div>
7979
<collection-creator
8080
:oncancel="oncancel"
81-
@hide-original-toggle="hideOriginalsToggle"
81+
:hideSourceItems="hideSourceItems"
82+
@onUpdateHideSourceItems="onUpdateHideSourceItems"
8283
@clicked-create="clickedCreate"
8384
@remove-extensions-toggle="removeExtensionsToggle"
8485
:creationFn="creationFn"
@@ -151,18 +152,18 @@
151152
</template>
152153

153154
<script>
154-
import CollectionCreator from "./common/CollectionCreator";
155+
import mixin from "./common/mixin";
155156
import STATES from "mvc/dataset/states";
156157
import _l from "utils/localization";
157158
import Vue from "vue";
158159
import BootstrapVue from "bootstrap-vue";
159160
160161
Vue.use(BootstrapVue);
161162
export default {
163+
mixins: [mixin],
162164
created() {
163165
this._elementsSetUp();
164166
},
165-
components: { CollectionCreator },
166167
data: function () {
167168
return {
168169
state: "build", //error
@@ -179,30 +180,6 @@ export default {
179180
invalidElements: [],
180181
};
181182
},
182-
props: {
183-
initialElements: {
184-
required: true,
185-
type: Array,
186-
},
187-
creationFn: {
188-
type: Function,
189-
required: true,
190-
},
191-
/** fn to call when the cancel button is clicked (scoped to this) - if falsy, no btn is displayed */
192-
oncancel: {
193-
type: Function,
194-
required: true,
195-
},
196-
oncreate: {
197-
type: Function,
198-
required: true,
199-
},
200-
defaultHideSourceItems: {
201-
type: Boolean,
202-
required: false,
203-
default: false,
204-
},
205-
},
206183
computed: {
207184
returnInvalidElementsLength: function () {
208185
return this.invalidElements.length > 0;
@@ -275,17 +252,14 @@ export default {
275252
},
276253
clickedCreate: function (collectionName) {
277254
if (this.state !== "error") {
278-
this.$emit("clicked-create", this.workingElements, this.collectionName, this.defaultHideSourceItems);
279-
return this.creationFn(this.workingElements, collectionName, this.defaultHideSourceItems)
255+
this.$emit("clicked-create", this.workingElements, this.collectionName, this.hideSourceItems);
256+
return this.creationFn(this.workingElements, collectionName, this.hideSourceItems)
280257
.done(this.oncreate)
281258
.fail(() => {
282259
this.state = "error";
283260
});
284261
}
285262
},
286-
hideOriginalsToggle: function () {
287-
this.defaultHideSourceItems = !this.defaultHideSourceItems;
288-
},
289263
/** string rep */
290264
toString: function () {
291265
return "PairCollectionCreator";

client/src/components/Collections/PairedListCollectionCreator.vue

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
</div>
101101
<collection-creator
102102
:oncancel="oncancel"
103-
@hide-original-toggle="hideOriginalsToggle"
103+
:hideSourceItems="hideSourceItems"
104+
@onUpdateHideSourceItems="onUpdateHideSourceItems"
104105
@clicked-create="clickedCreate"
105106
@remove-extensions-toggle="removeExtensionsToggle"
106107
:renderExtensionsToggle="true"
@@ -424,7 +425,7 @@
424425
</template>
425426
<script>
426427
import _l from "utils/localization";
427-
import CollectionCreator from "./common/CollectionCreator";
428+
import mixin from "./common/mixin";
428429
import UnpairedDatasetElementView from "./UnpairedDatasetElementView";
429430
import levenshteinDistance from "utils/levenshtein";
430431
import PairedElementView from "./PairedElementView";
@@ -438,13 +439,13 @@ import BootstrapVue from "bootstrap-vue";
438439
439440
Vue.use(BootstrapVue);
440441
export default {
442+
mixins: [mixin],
441443
created() {
442444
this.strategy = this.autopairLCS;
443445
this.filters = this.commonFilters[this.filters] || this.commonFilters[this.DEFAULT_FILTERS];
444446
this._elementsSetUp();
445447
},
446448
components: {
447-
CollectionCreator,
448449
UnpairedDatasetElementView,
449450
PairedElementView,
450451
Splitpanes,
@@ -546,30 +547,6 @@ export default {
546547
duplicatePairNames: [],
547548
};
548549
},
549-
props: {
550-
initialElements: {
551-
required: true,
552-
type: Array,
553-
},
554-
creationFn: {
555-
type: Function,
556-
required: true,
557-
},
558-
/** fn to call when the cancel button is clicked (scoped to this) - if falsy, no btn is displayed */
559-
oncancel: {
560-
type: Function,
561-
required: true,
562-
},
563-
oncreate: {
564-
type: Function,
565-
required: true,
566-
},
567-
defaultHideSourceItems: {
568-
type: Boolean,
569-
required: false,
570-
default: false,
571-
},
572-
},
573550
methods: {
574551
l(str) {
575552
// _l conflicts private methods of Vue internals, expose as l instead
@@ -993,8 +970,8 @@ export default {
993970
clickedCreate: function (collectionName) {
994971
this.checkForDuplicates();
995972
if (this.state !== "error") {
996-
this.$emit("clicked-create", this.workingElements, this.collectionName, this.defaultHideSourceItems);
997-
return this.creationFn(this.pairedElements, collectionName, this.defaultHideSourceItems)
973+
this.$emit("clicked-create", this.workingElements, this.collectionName, this.hideSourceItems);
974+
return this.creationFn(this.pairedElements, collectionName, this.hideSourceItems)
998975
.done(this.oncreate)
999976
.fail(() => {
1000977
this.state = "error";
@@ -1014,9 +991,6 @@ export default {
1014991
});
1015992
this.state = valid ? "build" : "error";
1016993
},
1017-
hideOriginalsToggle: function () {
1018-
this.defaultHideSourceItems = !this.defaultHideSourceItems;
1019-
},
1020994
stripExtension(name) {
1021995
return name.includes(".") ? name.substring(0, name.lastIndexOf(".")) : name;
1022996
},

client/src/components/Collections/common/CollectionCreator.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@
4747
</label>
4848
<label class="setting-prompt float-right">
4949
{{ hideOriginalsText }}
50-
<input
51-
class="hide-originals float-right"
52-
type="checkbox"
53-
@click="$emit('hide-original-toggle')"
54-
checked
55-
/>
50+
<input class="hide-originals float-right" type="checkbox" v-model="localHideSourceItems" />
5651
</label>
5752
</div>
5853
<div class="clear">
@@ -102,6 +97,10 @@ export default {
10297
type: Boolean,
10398
default: false,
10499
},
100+
hideSourceItems: {
101+
type: Boolean,
102+
required: true,
103+
},
105104
},
106105
computed: {
107106
validInput: function () {
@@ -118,6 +117,7 @@ export default {
118117
isExpanded: false,
119118
collectionName: "",
120119
removeFileExtensionsText: "Remove file extensions?",
120+
localHideSourceItems: this.hideSourceItems,
121121
};
122122
},
123123
methods: {
@@ -135,8 +135,10 @@ export default {
135135
_getName: function () {
136136
return this.collectionName;
137137
},
138-
_setUpCommonSettings: function (attributes) {
139-
this.hideOriginals = attributes.defaultHideSourceItems || false;
138+
},
139+
watch: {
140+
localHideSourceItems() {
141+
this.$emit("onUpdateHideSourceItems", this.localHideSourceItems);
140142
},
141143
},
142144
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import CollectionCreator from "./CollectionCreator";
2+
3+
export default {
4+
components: {
5+
CollectionCreator,
6+
},
7+
props: {
8+
initialElements: {
9+
required: true,
10+
type: Array,
11+
},
12+
creationFn: {
13+
type: Function,
14+
required: true,
15+
},
16+
/** fn to call when the cancel button is clicked (scoped to this) - if falsy, no btn is displayed */
17+
oncancel: {
18+
type: Function,
19+
required: true,
20+
},
21+
oncreate: {
22+
type: Function,
23+
required: true,
24+
},
25+
defaultHideSourceItems: {
26+
type: Boolean,
27+
required: false,
28+
default: false,
29+
},
30+
},
31+
data() {
32+
return {
33+
hideSourceItems: this.defaultHideSourceItems,
34+
};
35+
},
36+
methods: {
37+
onUpdateHideSourceItems(hideSourceItems) {
38+
this.hideSourceItems = hideSourceItems;
39+
},
40+
},
41+
};

0 commit comments

Comments
 (0)