Skip to content
Closed
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
3 changes: 2 additions & 1 deletion LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ public async Task<FileUploadResult> UploadArticleFile(IFormCollection inputForm)
var file = inputForm.Files[0];
int.TryParse(inputForm["resourceVersionId"], out int resourceVersionId);
int.TryParse(inputForm["changeingFileId"], out int existingFileId);
int.TryParse(inputForm["fileSize"], out int fileSize);
var currentUserId = this.User.Identity.GetCurrentUserId();
return await this.contributeService.ProcessArticleFileAsync(resourceVersionId, file, existingFileId, currentUserId);
return await this.contributeService.ProcessArticleFileAsync(resourceVersionId, file, fileSize, existingFileId, currentUserId);
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion LearningHub.Nhs.WebUI/Interfaces/IContributeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ public interface IContributeService
/// </summary>
/// <param name="resourceVersionId">Resource version id.</param>
/// <param name="file">File.</param>
/// <param name="fileSize">fileSize.</param>
/// <param name="changeingFileId">Changing file id.</param>
/// <param name="currentUserId">Current user id.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
Task<FileUploadResult> ProcessArticleFileAsync(int resourceVersionId, IFormFile file, int changeingFileId, int currentUserId);
Task<FileUploadResult> ProcessArticleFileAsync(int resourceVersionId, IFormFile file, int fileSize,int changeingFileId, int currentUserId);

/// <summary>
/// The ProcessResourceAttachedFileAsync.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
return this.resourceDetails.resourceLicenceId > 0;
},
locationTabComplete(): boolean {
return this.resourceDetails.resourceCatalogueId > 0;
return this.resourceDetails.resourceCatalogueId > 1;
},
certificateTabComplete(): boolean {
return this.resourceDetails.certificateEnabled !== null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
<ckeditorwithhint v-on:blur="setEndGuidance"
v-on:inputValidity="setGuidanceValidity"
:maxLength="1000"
:initialValue="endGuidance"
:for="guidance"
:id="guidance"/>
:initialValue="endGuidance"/>
</div>
<div class="tip">
<h3>Tip</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,57 @@

<!-- The following heading has an id to allow the CatalogueSelector component to reference this (using aria-labelledby) -->
<h3 id="primary-catalogue-heading" class="nhsuk-heading-m mt-5 mb-10">Primary catalogue</h3>

<div class="contribute-location-tab-catalogue-block">
<CatalogueView v-if="resourceDetails.resourceCatalogueId > 0"
v-bind:catalogue="savedCatalogue"
v-on:change-click="showSelector"
v-bind:selection-in-progress="selectionInProgress"
v-bind:allow-change="allowCatalogueChange"/>
<div class="contribute-location-tab-divider" v-if="isDividerVisible"></div>
<CatalogueSelector v-if="selectionInProgress"
v-bind:resource-details="resourceDetails"
v-bind:user-catalogues="userCatalogues"
v-on:save="hideSelector"/>
<!-- When catalogue has a value -->
<template v-if="savedCatalogue">
<CatalogueView v-if="resourceDetails.resourceCatalogueId >= 0"
:catalogue="savedCatalogue"
@change-click="showSelector"
:selection-in-progress="selectionInProgress"
:allow-change="allowCatalogueChange"
:resourceCatalogueId=resourceDetails.resourceCatalogueId />
<div class="contribute-location-tab-divider"
v-if="isDividerVisible"></div>
<CatalogueSelector v-if="selectionInProgress"
:resource-details="resourceDetails"
:user-catalogues="userCatalogues"
@save="hideSelector"
:resourceCatalogueId=resourceDetails.resourceCatalogueId />
</template>

<!-- When catalogue has no value -->
<div v-else>
<CatalogueView :catalogue="savedCatalogue"
@change-click="showSelector"
:selection-in-progress="selectionInProgress"
:allow-change="allowCatalogueChange"
:resourceCatalogueId="0" />
<div class="contribute-location-tab-divider"
v-if="isDividerVisible"></div>
<CatalogueSelector v-if="selectionInProgress"
:resource-details="resourceDetails"
:user-catalogues="userCatalogues"
@save="hideSelector"
:resourceCatalogueId="0" />
</div>
</div>



</div>
</div>
</template>

<script lang="ts">
import Vue, { PropOptions } from 'vue';

import DescriptionEditor from "./components/DescriptionEditor.vue";
import CatalogueSelector from "./components/CatalogueSelector.vue";
import CatalogueView from "./components/CatalogueView.vue";

import { CatalogueModel } from "../models/catalogueModel";
import { ContributeResourceDetailModel } from '../models/contribute/contributeResourceModel';

export default Vue.extend({
props: {
resourceDetails: { type: Object } as PropOptions<ContributeResourceDetailModel>,
Expand All @@ -57,24 +81,29 @@
if (this.resourceDetails.resourceCatalogueId > 0) {
return this.userCatalogues.find(c => c.nodeId == this.resourceDetails.resourceCatalogueId);
}

return new CatalogueModel({ nodeId: 0 });
},
resourceDescription(): string {
return this.resourceDetails.description;
return this.resourceDetails.description;
},
isDividerVisible(): boolean {
return this.resourceDetails.resourceCatalogueId > 0 && this.selectionInProgress;
return this.resourceDetails.resourceCatalogueId >= 0 && this.selectionInProgress;
},
allowCatalogueChange(): boolean {
return (this.resourceDetails.resourceCatalogueId === this.resourceDetails.nodeId) || // allow if user is contributing into the catalogue root
!Boolean(this.$route.query.initialCreate); // or if the user is editing an existing draft (initialCreate=false)
}
!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)
},
onChangeClick() {
this.$emit('change-click');
},
},
methods: {
hideSelector(){
hideSelector() {
this.selectionInProgress = false;
},
showSelector(){
showSelector() {
this.selectionInProgress = true;
}
},
Expand All @@ -86,7 +115,7 @@

.contribute-location-tab {
min-height: 571px;

&-catalogue-block {
background-color: $nhsuk-white;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
<template>
<div class="catalogue-selector p-24">
<div class="mb-3">Select a catalogue to add this resource to.</div>

<CatalogueSelectorAccordion/>

<div class="form-group">
<select class="form-control nhsuk-input" aria-labelledby="primary-catalogue-heading" id="catalogue" v-model="selectedCatalogue" @change="catalogueChange">
<option disabled v-bind:value="{ nodeId: 0 }">Please choose...</option>
<option v-for="catalogue in userCatalogues" :value="catalogue">
{{getCatalogueName(catalogue)}}
</option>
</select>

<CatalogueSelectorAccordion />
<div v-if="resourceCatalogueId > 0">
<div class="form-group">
<select class="form-control nhsuk-input" aria-labelledby="primary-catalogue-heading" id="catalogue" v-model="selectedCatalogue" @change="catalogueChange">
<option disabled v-bind:value="{ nodeId: 0 }">Please choose...</option>
<option v-for="catalogue in userCatalogues" :value="catalogue">
{{getCatalogueName(catalogue)}}
</option>
</select>
</div>
<div class="warning-content" v-if="selectedCatalogue.hidden">
<span>
You have selected a hidden catalogue. If you publish this resource, learners will only be able
to access it when the catalogue is made available by Learning Hub platform administrators.
</span>
</div>
<Button color="green" size="thin" class="save-button mt-20" v-on:click="savePrimaryCatalogue" v-bind:disabled="!selectedCatalogueIsValid">Save</Button>
</div>

<div class="warning-content" v-if="selectedCatalogue.hidden">
<span>
You have selected a hidden catalogue. If you publish this resource, learners will only be able
to access it when the catalogue is made available by Learning Hub platform administrators.
</span>
<div v-else>
<div class="form-group">
<select class="form-control nhsuk-input" aria-labelledby="primary-catalogue-heading" id="catalogue" v-model="selectedCatalogue" @change="catalogueChange">
<option disabled v-bind:value="{ nodeId: 0 }">Please choose...</option>
<option v-for="catalogue in userCatalogues" :value="catalogue">
{{getCatalogueName(catalogue)}}
</option>
</select>
</div>
<Button color="green" size="thin" class="save-button mt-20" v-on:click="savePrimaryCatalogue" >Save</Button>
</div>

<Button color="green" size="thin" class="save-button mt-20" v-on:click="savePrimaryCatalogue" v-bind:disabled="!selectedCatalogueIsValid">Save</Button>
</div>
</template>

Expand All @@ -29,14 +39,19 @@

import Button from "../../globalcomponents/Button.vue";
import CatalogueSelectorAccordion from "./CatalogueSelectorAccordion.vue"

import { CatalogueModel } from "../../models/catalogueModel";
import { ContributeResourceDetailModel } from "../../models/contribute/contributeResourceModel";

export default Vue.extend({
props: {
resourceDetails: { type: Object } as PropOptions<ContributeResourceDetailModel>,
userCatalogues: { type: Array } as PropOptions<CatalogueModel[]>,
resourceCatalogueId: {
type: Number,
required: false,
default: null
}
},
components: {
Button,
Expand All @@ -49,13 +64,16 @@
},
computed: {
selectedCatalogueIsValid(): boolean {
return this.selectedCatalogue.nodeId > 0;
},
return (this.selectedCatalogue.nodeId > 0 || this.resourceCatalogueId === 0);
},
},
created() {
if (this.resourceDetails.resourceCatalogueId > 0) {
this.selectedCatalogue = this.userCatalogues.find(c => c.nodeId == this.resourceDetails.resourceCatalogueId);
}
else {
this.selectedCatalogue = new CatalogueModel({ nodeId: 0 });
}
},
methods: {
getCatalogueName(catalogue: CatalogueModel) {
Expand All @@ -74,21 +92,23 @@
this.$emit('save');
}
},

})
</script>

<style lang="scss">
@use '../../../../Styles/abstracts/all' as *;

.catalogue-selector {
background-color: $nhsuk-white;
}

button.save-button {
font-size: 19px;
padding: 8px 20px;
min-width: unset
}

select.form-control {
border: 2px solid $nhsuk-grey;
height: 40px !important;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
<template>
<div class="p-24 d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center justify-content-between" v-if="resourceCatalogueId > 0">
<picture v-if="!logoErrorOnLoad">
<img class="logo"
v-bind:src="`/api/catalogue/download-image/${catalogue.badgeUrl}`"
v-bind:alt="`Logo for ${catalogue.name} Catalogue`"
<img class="logo"
v-bind:src="`/api/catalogue/download-image/${catalogue.badgeUrl}`"
v-bind:alt="`Logo for ${catalogue.name} Catalogue`"
@error="errorLoadingLogo">
</picture>
<div class="ml-15">{{catalogue.name}}</div>
</div>
<div v-else>
<p>No catalogue available.</p>
</div>
<a href="#" class="change-text-button accessible-link" v-if="!selectionInProgress && allowChange" v-on:click.prevent="onChangeClick">Change</a>
</div>
</template>

<script lang="ts">
import Vue, { PropOptions } from 'vue';

import { CatalogueModel } from "../../models/catalogueModel";

export default Vue.extend({
props: {
catalogue: { type: Object } as PropOptions<CatalogueModel>,
selectionInProgress: Boolean,
allowChange: Boolean
},
data() {
return {
logoErrorOnLoad: false,
}
},
methods: {
onChangeClick() {
this.$emit('change-click');
import Vue, { PropOptions } from 'vue';
import { CatalogueModel } from "../../models/catalogueModel";
export default Vue.extend({
props: {
catalogue: { type: Object } as PropOptions<CatalogueModel>,
selectionInProgress: Boolean,
allowChange: Boolean,
resourceCatalogueId: {
type: Number,
required: false,
default: null
}
},
errorLoadingLogo() {
this.logoErrorOnLoad = true;
data() {
return {
logoErrorOnLoad: false,
}
},
methods: {
onChangeClick() {
this.$emit('change-click');
},
errorLoadingLogo() {
this.logoErrorOnLoad = true;
}
}
}
})
})
</script>

<style lang="scss" scoped>
@use '../../../../Styles/abstracts/all' as *;

Expand All @@ -50,4 +54,4 @@ export default Vue.extend({
max-height: 60px;
}
}
</style>
</style>
Loading
Loading