Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS-773: Add functionality to select multiple training types to pull reports #216

Merged
merged 1 commit into from
Feb 16, 2024
Merged
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
2 changes: 1 addition & 1 deletion api/models/dto/TrainingReportSearchDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TrainingReportSearchDto
{
public int? regionId { get; set; }
public int? locationId { get; set; }
public int? reportSubtypeId { get; set; }
public int[]? reportSubtypeIds { get; set; }
public DateTimeOffset? startDate { get; set; }
public DateTimeOffset? endDate { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions api/services/ManageTypesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public async Task<List<LookupCode>> GetAll(LookupTypes? codeType, int? locationI
return lookupCodes;
}

public async Task<List<LookupCode>> GetAllForReports(int? id, LookupTypes? codeType, int? locationId, bool? mandatory, bool showExpired = false)
public async Task<List<LookupCode>> GetAllForReports(int[]? ids, LookupTypes? codeType, int? locationId, bool? mandatory, bool showExpired = false)
{
var lookupCodes = await Db.LookupCode.AsNoTracking()
.Include(lc => lc.SortOrder.Where(so => so.LocationId == locationId))
.Where(lc =>
(id == null || lc.Id == id) &&
(ids == null || ids.Length==0 || ids.Contains(lc.Id)) &&
(codeType == null || lc.Type == codeType) &&
(locationId == null || lc.LocationId == null || lc.LocationId == locationId) &&
(mandatory == null || lc.Mandatory == mandatory) &&
Expand Down
4 changes: 2 additions & 2 deletions api/services/usermanagement/TrainingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public async Task<List<TrainingReportDto>> GetSheriffsTrainingReports(TrainingRe

var sheriffs = await sheriffQuery.ToListAsync();

List<LookupCode> mandatoryTrainings = await ManageTypesService.GetAllForReports(trainingReportSearch.reportSubtypeId, LookupTypes.TrainingType, null, true, false);
List<LookupCode> optionalTrainings = await ManageTypesService.GetAllForReports(trainingReportSearch.reportSubtypeId, LookupTypes.TrainingType, null, false, false);
List<LookupCode> mandatoryTrainings = await ManageTypesService.GetAllForReports(trainingReportSearch.reportSubtypeIds, LookupTypes.TrainingType, null, true, false);
List<LookupCode> optionalTrainings = await ManageTypesService.GetAllForReports(trainingReportSearch.reportSubtypeIds, LookupTypes.TrainingType, null, false, false);

var sheriffTrainings = new List<TrainingReportDto>();

Expand Down
3 changes: 3 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/vue-fontawesome": "^2.0.0",
"@types/underscore": "^1.10.0",
"@mdi/font": "^6.5.95",
"ansi-regex": "^6.0.1",
"axios": "^0.21.4",
"axios-auth-refresh": "^3.2.1",
Expand Down Expand Up @@ -44,6 +45,7 @@
"vue-property-decorator": "^8.4.2",
"vue-resource": "^1.5.3",
"vue-router": "^3.1.6",
"vuetify": "^2.6.3",
"vuex": "^3.3.0",
"vuex-class": "^0.3.2",
"vuex-module-decorators": "^0.17.0"
Expand All @@ -68,6 +70,7 @@
"ts-loader": "^7.0.1",
"tslib": "^1.11.1",
"typescript": "3.8.3",
"vue-cli-plugin-vuetify": "~2.0.5",
"vue-template-compiler": "2.6.11",
"webpack-bundle-analyzer": "^4.5.0"
},
Expand Down
130 changes: 104 additions & 26 deletions web/src/components/MyTeam/ViewReports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,51 @@
</b-form-select>
</b-form-group>
</b-col>
<b-col v-if="reportParameters.reportType && reportParameters.reportType == 'Training'" >
<b-form-group style="margin:0;">
<label class="h4 mb-2 p-0 float-left"> Training Type </label>
<b-form-select
@change="clearReports()"
<b-col cols="4" v-if="reportParameters.reportType && reportParameters.reportType == 'Training'" >
<v-app class="vuetify">
<label class="h4 mb-2 p-0 float-left mr-auto"> Training Type </label>
<v-select
@change="clearReports()"
v-model="reportParameters.reportSubtype"
:state = "reportSubTypeState?null:false">
<b-form-select-option value="All">
All Training Types
</b-form-select-option>
<b-form-select-option
state=true
v-for="trainingType in trainingTypeOptions"
:key="trainingType.id"
:value="trainingType.id">
{{trainingType.code}}
</b-form-select-option>
</b-form-select>
</b-form-group>
:items="trainingTypeOptions"
label="Select"
item-text="code"
item-value="id"
:error="!reportSubTypeState"
multiple
flat
hide-details
solo>
<template v-slot:prepend-item>
<v-list-item
ripple
@mousedown.prevent
@click="toggle"
>
<v-list-item-action>
<v-icon :color="reportParameters.reportSubtype.length > 0 ? 'indigo darken-4' : ''">
{{ icon }}
</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
Select All
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider class="mt-2"></v-divider>
</template>
<template v-slot:selection="{ item, index }">
<span v-if="reportParameters.reportSubtype.length==1">
{{item.code | truncate(25)}}
</span>
<span v-else-if="index === 0" class="grey--text text-caption">
<span v-if="reportParameters.reportSubtype.length<trainingTypeOptions.length">{{ reportParameters.reportSubtype.length }} training types selected</span>
<span v-else>All training types selected</span>
</span>
</template>
</v-select>
</v-app>
</b-col>
</b-row>
<b-row class="mt-4 mx-0">
Expand Down Expand Up @@ -233,7 +259,7 @@
error = '';
updateRegionId = 0;
printReady = false;
reportParameters = {region: 'All', location: 'All', reportSubtype: 'All', reportType:'Training'} as reportInfoType;
reportParameters = {region: 'All', location: 'All', reportSubtype: [0], reportType:'Training'} as reportInfoType;
reportDateRange = { startDate:'', endDate:'', valid:false} as dateRangeInfoType
trainingReportData: trainingReportInfoType[] = []
filteredTrainingReportData: trainingReportInfoType[] = []
Expand Down Expand Up @@ -272,16 +298,16 @@
this.dataReady = false;
this.clearReports();
this.reportParameters.region = 'All';
this.reportParameters.location = 'All';
this.reportParameters.reportSubtype = 'All';
this.reportParameters.location = 'All';
this.searching = false;
this.generatingReport = false;
this.locationOptionsList = this.locationList;
this.getTrainingTypes();
this.getTrainingTypes();
}

public clearReports(){
this.dataLoaded = false;
this.reportSubTypeState = true
this.trainingReportData = [];
this.excludedTrainingReportData = [];
}
Expand All @@ -295,7 +321,7 @@
if (!this.reportParameters.reportType){
this.reportTypeState = false;
}
else if (!this.reportParameters.reportSubtype){
else if (this.reportParameters.reportSubtype?.length==0){
this.reportSubTypeState = false;
}
else {
Expand All @@ -304,7 +330,7 @@
regionId: this.reportParameters.region == 'All'? null : this.reportParameters.region,
locationId: this.reportParameters.location == 'All'? null : this.reportParameters.location,
// reportType: this.reportParameters.reportType,
reportSubtypeId: this.reportParameters.reportSubtype == 'All'? null : this.reportParameters.reportSubtype,
reportSubtypeIds: this.likesAllSubtypes? [] : this.reportParameters.reportSubtype,
startDate: this.reportDateRange.valid? this.reportDateRange.startDate : null,
endDate: this.reportDateRange.valid? this.reportDateRange.endDate : null
}
Expand Down Expand Up @@ -382,6 +408,7 @@
if(response.data){
this.trainingTypeOptions = response.data;
}
this.reportParameters.reportSubtype = this.trainingTypeOptions.map(t => t.id)
this.dataReady = true;

},err => {
Expand All @@ -399,7 +426,7 @@

const url = 'api/sheriff/updateExcused';
this.$http.put(url, body)
.then(response => {
.then(() => {
this.find()
}, err => {
this.error = err.response.data.error;
Expand Down Expand Up @@ -441,10 +468,61 @@
this.paginationExcludedKey++;
}

public toggle () {
Vue.nextTick(() => {
if (this.likesAllSubtypes) {
this.reportParameters.reportSubtype = []
} else {
this.reportParameters.reportSubtype = this.trainingTypeOptions.map(t => t.id)
}
})
}

get likesAllSubtypes(){
return this.trainingTypeOptions.length==this.reportParameters.reportSubtype.length
}

get likesSomeSubtypes() {
return this.trainingTypeOptions.length > 0 && !this.likesAllSubtypes
}

get icon () {
if (this.likesAllSubtypes) return 'mdi-close-box'
if (this.likesSomeSubtypes) return 'mdi-minus-box'
return 'mdi-checkbox-blank-outline'
}

}
</script>

<style scoped>
<style scoped lang="scss">

::v-deep .vuetify{
@import "@/styles/vuetify.scss";
.v-application--wrap{
height: 2rem;
min-height:2rem !important;
}

.v-text-field .v-input__control .v-input__slot {
min-height: 2.4rem !important;
display: flex !important;
align-items: center !important;
border: 1px solid #adb5bd;
}

.v-text-field.error--text .v-input__control .v-input__slot {
min-height: 2.4rem !important;
display: flex !important;
align-items: center !important;
border: 1px solid #f71b03;
}

.v-list-item__content {
flex: none;
margin-left: 1rem;
}
}

.card {
border: white;
Expand Down
4 changes: 4 additions & 0 deletions web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ import store from './store/index'
import http from "./plugins/http";
import "./filters"
import LoadingSpinner from "@components/LoadingSpinner.vue";
import Vuetify from 'vuetify'
import '@mdi/font/css/materialdesignicons.css'

library.add(faGraduationCap);
library.add(faSuitcase);
library.add(faSignInAlt);
library.add(faSignOutAlt);

Vue.use(Vuetify)
Vue.use(VueCookies);
Vue.use(VueRouter);
Vue.use(BootstrapVue);
Expand All @@ -41,6 +44,7 @@ if (location.pathname == "/")
history.pushState({page: "home"}, "", process.env.BASE_URL)

new Vue({
vuetify: new Vuetify({}),
router,
store,
render: h => h(App)
Expand Down
Loading