Skip to content

Commit 228dd09

Browse files
TD-5892: Issue with the resources when try to edit and republish which have been previously published under 'community contributio
1 parent 70f9491 commit 228dd09

File tree

8 files changed

+143
-86
lines changed

8 files changed

+143
-86
lines changed

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute-resource/Contribute.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@
432432
return this.resourceDetails.resourceLicenceId > 0;
433433
},
434434
locationTabComplete(): boolean {
435-
return this.resourceDetails.resourceCatalogueId > 0;
435+
return this.resourceDetails.resourceCatalogueId > 1;
436436
},
437437
certificateTabComplete(): boolean {
438438
return this.resourceDetails.certificateEnabled !== null;

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute-resource/ContributeAssessmentSettings.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@
7474
<ckeditorwithhint v-on:blur="setEndGuidance"
7575
v-on:inputValidity="setGuidanceValidity"
7676
:maxLength="1000"
77-
:initialValue="endGuidance"
78-
:for="guidance"
79-
:id="guidance"/>
77+
:initialValue="endGuidance"/>
8078
</div>
8179
<div class="tip">
8280
<h3>Tip</h3>

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute-resource/ContributeLocationTab.vue

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,58 @@
77

88
<!-- The following heading has an id to allow the CatalogueSelector component to reference this (using aria-labelledby) -->
99
<h3 id="primary-catalogue-heading" class="nhsuk-heading-m mt-5 mb-10">Primary catalogue</h3>
10-
10+
1111
<div class="contribute-location-tab-catalogue-block">
12-
<CatalogueView v-if="resourceDetails.resourceCatalogueId > 0"
13-
v-bind:catalogue="savedCatalogue"
14-
v-on:change-click="showSelector"
15-
v-bind:selection-in-progress="selectionInProgress"
16-
v-bind:allow-change="allowCatalogueChange"/>
17-
<div class="contribute-location-tab-divider" v-if="isDividerVisible"></div>
18-
<CatalogueSelector v-if="selectionInProgress"
19-
v-bind:resource-details="resourceDetails"
20-
v-bind:user-catalogues="userCatalogues"
21-
v-on:save="hideSelector"/>
12+
<!-- When catalogue has a value -->
13+
<template v-if="savedCatalogue">
14+
<CatalogueView v-if="resourceDetails.resourceCatalogueId >= 0"
15+
:catalogue="savedCatalogue"
16+
@change-click="showSelector"
17+
:selection-in-progress="selectionInProgress"
18+
:allow-change="allowCatalogueChange"
19+
:resourceCatalogueId=resourceDetails.resourceCatalogueId />
20+
<div class="contribute-location-tab-divider"
21+
v-if="isDividerVisible"></div>
22+
<CatalogueSelector v-if="selectionInProgress"
23+
:resource-details="resourceDetails"
24+
:user-catalogues="userCatalogues"
25+
@save="hideSelector"
26+
:resourceCatalogueId=resourceDetails.resourceCatalogueId />
27+
</template>
28+
29+
<!-- When catalogue has no value -->
30+
<div v-else>
31+
<p>No catalogue available.</p>
32+
<CatalogueView :catalogue="savedCatalogue"
33+
@change-click="showSelector"
34+
:selection-in-progress="selectionInProgress"
35+
:allow-change="allowCatalogueChange"
36+
:resourceCatalogueId="0" />
37+
<div class="contribute-location-tab-divider"
38+
v-if="isDividerVisible"></div>
39+
<CatalogueSelector v-if="selectionInProgress"
40+
:resource-details="resourceDetails"
41+
:user-catalogues="userCatalogues"
42+
@save="hideSelector"
43+
:resourceCatalogueId="0" />
44+
</div>
2245
</div>
46+
47+
48+
2349
</div>
2450
</div>
2551
</template>
26-
2752
<script lang="ts">
2853
import Vue, { PropOptions } from 'vue';
2954
3055
import DescriptionEditor from "./components/DescriptionEditor.vue";
3156
import CatalogueSelector from "./components/CatalogueSelector.vue";
3257
import CatalogueView from "./components/CatalogueView.vue";
33-
58+
3459
import { CatalogueModel } from "../models/catalogueModel";
3560
import { ContributeResourceDetailModel } from '../models/contribute/contributeResourceModel';
36-
61+
3762
export default Vue.extend({
3863
props: {
3964
resourceDetails: { type: Object } as PropOptions<ContributeResourceDetailModel>,
@@ -57,24 +82,28 @@
5782
if (this.resourceDetails.resourceCatalogueId > 0) {
5883
return this.userCatalogues.find(c => c.nodeId == this.resourceDetails.resourceCatalogueId);
5984
}
85+
6086
return new CatalogueModel({ nodeId: 0 });
6187
},
6288
resourceDescription(): string {
6389
return this.resourceDetails.description;
6490
},
6591
isDividerVisible(): boolean {
66-
return this.resourceDetails.resourceCatalogueId > 0 && this.selectionInProgress;
92+
return this.resourceDetails.resourceCatalogueId >= 0 && this.selectionInProgress;
6793
},
6894
allowCatalogueChange(): boolean {
69-
return (this.resourceDetails.resourceCatalogueId === this.resourceDetails.nodeId) || // allow if user is contributing into the catalogue root
70-
!Boolean(this.$route.query.initialCreate); // or if the user is editing an existing draft (initialCreate=false)
71-
}
95+
return (!Boolean(this.$route.query.initialCreate)); // allow if user is contributing into the catalogue root // or if the user is editing an existing draft (initialCreate=false)
96+
//this.resourceDetails.resourceCatalogueId === this.resourceDetails.nodeId) ||
97+
},
98+
onChangeClick() {
99+
this.$emit('change-click');
100+
},
72101
},
73102
methods: {
74-
hideSelector(){
103+
hideSelector() {
75104
this.selectionInProgress = false;
76105
},
77-
showSelector(){
106+
showSelector() {
78107
this.selectionInProgress = true;
79108
}
80109
},
@@ -86,7 +115,7 @@
86115
87116
.contribute-location-tab {
88117
min-height: 571px;
89-
118+
90119
&-catalogue-block {
91120
background-color: $nhsuk-white;
92121
}

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute-resource/components/CatalogueSelector.vue

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
11
<template>
22
<div class="catalogue-selector p-24">
33
<div class="mb-3">Select a catalogue to add this resource to.</div>
4-
5-
<CatalogueSelectorAccordion/>
6-
7-
<div class="form-group">
8-
<select class="form-control nhsuk-input" aria-labelledby="primary-catalogue-heading" id="catalogue" v-model="selectedCatalogue" @change="catalogueChange">
9-
<option disabled v-bind:value="{ nodeId: 0 }">Please choose...</option>
10-
<option v-for="catalogue in userCatalogues" :value="catalogue">
11-
{{getCatalogueName(catalogue)}}
12-
</option>
13-
</select>
4+
5+
<CatalogueSelectorAccordion />
6+
<div v-if="resourceCatalogueId > 0">
7+
<div class="form-group">
8+
<select class="form-control nhsuk-input" aria-labelledby="primary-catalogue-heading" id="catalogue" v-model="selectedCatalogue" @change="catalogueChange">
9+
<option disabled v-bind:value="{ nodeId: 0 }">Please choose...</option>
10+
<option v-for="catalogue in userCatalogues" :value="catalogue">
11+
{{getCatalogueName(catalogue)}}
12+
</option>
13+
</select>
14+
</div>
15+
<div class="warning-content" v-if="selectedCatalogue.hidden">
16+
<span>
17+
You have selected a hidden catalogue. If you publish this resource, learners will only be able
18+
to access it when the catalogue is made available by Learning Hub platform administrators.
19+
</span>
20+
</div>
21+
<Button color="green" size="thin" class="save-button mt-20" v-on:click="savePrimaryCatalogue" v-bind:disabled="!selectedCatalogueIsValid">Save</Button>
1422
</div>
15-
16-
<div class="warning-content" v-if="selectedCatalogue.hidden">
17-
<span>
18-
You have selected a hidden catalogue. If you publish this resource, learners will only be able
19-
to access it when the catalogue is made available by Learning Hub platform administrators.
20-
</span>
23+
<div v-else>
24+
<div class="form-group">
25+
<select class="form-control nhsuk-input" aria-labelledby="primary-catalogue-heading" id="catalogue" v-model="selectedCatalogue" @change="catalogueChange">
26+
<option disabled v-bind:value="{ nodeId: 0 }">Please choose...</option>
27+
<option v-for="catalogue in userCatalogues" :value="catalogue">
28+
{{getCatalogueName(catalogue)}}
29+
</option>
30+
</select>
31+
</div>
32+
<Button color="green" size="thin" class="save-button mt-20" v-on:click="savePrimaryCatalogue" >Save</Button>
2133
</div>
22-
23-
<Button color="green" size="thin" class="save-button mt-20" v-on:click="savePrimaryCatalogue" v-bind:disabled="!selectedCatalogueIsValid">Save</Button>
2434
</div>
2535
</template>
2636

@@ -29,14 +39,19 @@
2939
3040
import Button from "../../globalcomponents/Button.vue";
3141
import CatalogueSelectorAccordion from "./CatalogueSelectorAccordion.vue"
32-
42+
3343
import { CatalogueModel } from "../../models/catalogueModel";
3444
import { ContributeResourceDetailModel } from "../../models/contribute/contributeResourceModel";
35-
45+
3646
export default Vue.extend({
3747
props: {
3848
resourceDetails: { type: Object } as PropOptions<ContributeResourceDetailModel>,
3949
userCatalogues: { type: Array } as PropOptions<CatalogueModel[]>,
50+
resourceCatalogueId: {
51+
type: Number,
52+
required: false,
53+
default: null
54+
}
4055
},
4156
components: {
4257
Button,
@@ -49,13 +64,16 @@
4964
},
5065
computed: {
5166
selectedCatalogueIsValid(): boolean {
52-
return this.selectedCatalogue.nodeId > 0;
53-
},
67+
return (this.selectedCatalogue.nodeId > 0 || this.resourceCatalogueId === 0);
68+
},
5469
},
5570
created() {
5671
if (this.resourceDetails.resourceCatalogueId > 0) {
5772
this.selectedCatalogue = this.userCatalogues.find(c => c.nodeId == this.resourceDetails.resourceCatalogueId);
5873
}
74+
else {
75+
this.selectedCatalogue = new CatalogueModel({ nodeId: 0 });
76+
}
5977
},
6078
methods: {
6179
getCatalogueName(catalogue: CatalogueModel) {
@@ -74,21 +92,23 @@
7492
this.$emit('save');
7593
}
7694
},
77-
95+
7896
})
7997
</script>
8098

8199
<style lang="scss">
82100
@use '../../../../Styles/abstracts/all' as *;
83-
101+
84102
.catalogue-selector {
85103
background-color: $nhsuk-white;
86104
}
105+
87106
button.save-button {
88107
font-size: 19px;
89108
padding: 8px 20px;
90109
min-width: unset
91110
}
111+
92112
select.form-control {
93113
border: 2px solid $nhsuk-grey;
94114
height: 40px !important;
Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,49 @@
11
<template>
22
<div class="p-24 d-flex align-items-center justify-content-between">
3-
<div class="d-flex align-items-center justify-content-between">
3+
<div class="d-flex align-items-center justify-content-between" v-if="resourceCatalogueId > 0">
44
<picture v-if="!logoErrorOnLoad">
5-
<img class="logo"
6-
v-bind:src="`/api/catalogue/download-image/${catalogue.badgeUrl}`"
7-
v-bind:alt="`Logo for ${catalogue.name} Catalogue`"
5+
<img class="logo"
6+
v-bind:src="`/api/catalogue/download-image/${catalogue.badgeUrl}`"
7+
v-bind:alt="`Logo for ${catalogue.name} Catalogue`"
88
@error="errorLoadingLogo">
99
</picture>
1010
<div class="ml-15">{{catalogue.name}}</div>
1111
</div>
12+
<div v-else>
13+
<p>Please select a catalogue</p>
14+
</div>
1215
<a href="#" class="change-text-button accessible-link" v-if="!selectionInProgress && allowChange" v-on:click.prevent="onChangeClick">Change</a>
1316
</div>
1417
</template>
15-
1618
<script lang="ts">
17-
import Vue, { PropOptions } from 'vue';
18-
19-
import { CatalogueModel } from "../../models/catalogueModel";
20-
21-
export default Vue.extend({
22-
props: {
23-
catalogue: { type: Object } as PropOptions<CatalogueModel>,
24-
selectionInProgress: Boolean,
25-
allowChange: Boolean
26-
},
27-
data() {
28-
return {
29-
logoErrorOnLoad: false,
30-
}
31-
},
32-
methods: {
33-
onChangeClick() {
34-
this.$emit('change-click');
19+
import Vue, { PropOptions } from 'vue';
20+
import { CatalogueModel } from "../../models/catalogueModel";
21+
export default Vue.extend({
22+
props: {
23+
catalogue: { type: Object } as PropOptions<CatalogueModel>,
24+
selectionInProgress: Boolean,
25+
allowChange: Boolean,
26+
resourceCatalogueId: {
27+
type: Number,
28+
required: false,
29+
default: null
30+
}
3531
},
36-
errorLoadingLogo() {
37-
this.logoErrorOnLoad = true;
32+
data() {
33+
return {
34+
logoErrorOnLoad: false,
35+
}
36+
},
37+
methods: {
38+
onChangeClick() {
39+
this.$emit('change-click');
40+
},
41+
errorLoadingLogo() {
42+
this.logoErrorOnLoad = true;
43+
}
3844
}
39-
}
40-
})
45+
})
4146
</script>
42-
4347
<style lang="scss" scoped>
4448
@use '../../../../Styles/abstracts/all' as *;
4549
@@ -50,4 +54,4 @@ export default Vue.extend({
5054
max-height: 60px;
5155
}
5256
}
53-
</style>
57+
</style>

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute/CatalogueSelect.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
A catalogue is a curated set of resources that has its own web page.
2727
</p>
2828
<p>
29-
You can contribute a resource as an editor of a catalogue.
29+
You can contribute a resource as an editor of a catalogue.
3030
</p>
3131
<p>
3232
You can manage all resources that you have contributed in the My contributions area.
@@ -45,9 +45,11 @@
4545
</option>
4646
</select>
4747
</div>
48-
<div v-if="selectedCatalogue.hidden" class="highlighted-info">
49-
You have selected a hidden catalogue.
50-
If you publish this resource, learners will only be able to access it when the catalogue is made available by Learning Hub platform administrators.
48+
<div v-if="value > 1">
49+
<div v-if="selectedCatalogue.hidden" class="highlighted-info">
50+
You have selected a hidden catalogue.
51+
If you publish this resource, learners will only be able to access it when the catalogue is made available by Learning Hub platform administrators.
52+
</div>
5153
</div>
5254
</div>
5355
</div>
@@ -87,9 +89,12 @@
8789
},
8890
},
8991
created() {
90-
if (this.value > 0) {
92+
if (this.value > 1) {
9193
this.selectedCatalogue = this.userCatalogues.find(c => c.nodeId == this.value);
9294
}
95+
else {
96+
this.selectedCatalogue = new CatalogueModel({ nodeId: 0 });
97+
}
9398
}
9499
})
95100

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute/ContentCommon.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@
333333
return this.$store.state.resourceDetail.resourceType;
334334
},
335335
showCatalogueSelect(): boolean {
336-
return (this.resourceDetail.resourceCatalogueId === this.resourceDetail.nodeId) || // show if user is contributing into the catalogue root
337-
!Boolean(this.$route.query.initialCreate); // or if the user is editing an existing draft (initialCreate=false)
336+
//return (this.resourceDetail.resourceCatalogueId === this.resourceDetail.nodeId) || // show if user is contributing into the catalogue root
337+
// !Boolean(this.$route.query.initialCreate); // or if the user is editing an existing draft (initialCreate=false)
338+
return (!Boolean(this.$route.query.initialCreate));
338339
},
339340
newKeywordTrimmed(): string {
340341
return this.newKeyword?.trim().replace(/ +(?= )/g, '');

0 commit comments

Comments
 (0)