diff --git a/config/project-scratch-def.json b/config/project-scratch-def.json index a2f39fb..d510e7b 100755 --- a/config/project-scratch-def.json +++ b/config/project-scratch-def.json @@ -1,7 +1,9 @@ { "orgName": "spencerhsieh Company", "edition": "Developer", - "orgPreferences" : { - "enabled": ["S1DesktopEnabled"] + "settings": { + "lightningExperienceSettings": { + "enableS1DesktopEnabled": true + } } -} +} \ No newline at end of file diff --git a/force-app/main/default/classes/ganttChart.cls b/force-app/main/default/classes/ganttChart.cls index 5d30e96..185ef25 100755 --- a/force-app/main/default/classes/ganttChart.cls +++ b/force-app/main/default/classes/ganttChart.cls @@ -1,17 +1,23 @@ public with sharing class ganttChart { @AuraEnabled - public static Map getChartData(String recordId, String startTime, String endTime, Integer slotSize, List filterProjects, List filterRoles, String filterStatus) { + public static Map getChartData(String recordId, String startTime, String endTime, Integer slotSize, List filterProjects, List filterColors, List filterRoles, String filterStatus) { Map data = new Map(); - String query = 'SELECT Resource__c, Resource__r.Name, Resource__r.Active__c, Resource__r.Default_Role__c, Project__c, Project__r.Name, Project__r.Active__c, Project__r.Color__c, Start_Date__c, End_Date__c, Status__c, Effort__c FROM Allocation__c WHERE Start_Date__c <= :endDate AND End_Date__c >= :startDate AND (Project__c = NULL OR Project__r.Active__c = TRUE) AND Resource__r.Active__c = TRUE'; + String query = 'SELECT Resource__c, Resource__r.Name, Resource__r.Active__c, Resource__r.Default_Role__c, Resource__r.Status__c, Project__c, Project__r.Name, Project__r.Active__c, Project__r.Color__c, Start_Date__c, End_Date__c, Status__c, Effort__c FROM Allocation__c WHERE Start_Date__c <= :endDate AND End_Date__c >= :startDate AND (Project__c = NULL OR Project__r.Active__c = TRUE) AND Resource__r.Active__c = TRUE'; List allocations = new List(); Map projectById = new Map(); Map resourceById = new Map(); Set roles = new Set(); + //キム追記 + Set colors = new Set(); if (!filterProjects.isEmpty()) { query += ' AND Project__c IN :filterProjects'; } + + if (!filterColors.isEmpty()) { + query += ' AND Project__r.Color__c IN :filterColors'; + } /* if (!filterProjectRecords.isEmpty()) { query += ' AND Project__c IN :filterProjectRecords'; @@ -26,7 +32,6 @@ public with sharing class ganttChart { if (String.isNotEmpty(startTime) && String.isNotEmpty(endTime)) { Date startDate = DateTime.newInstance(Long.valueOf(startTime)).date(); - Date endDate = DateTime.newInstance(Long.valueOf(endTime)).date(); Integer days = startDate.daysBetween(endDate) + 1; slotSize = Integer.valueOf(slotSize); @@ -48,6 +53,7 @@ public with sharing class ganttChart { 'Id' => resource.get('Id'), 'Name' => resource.get('Name'), 'Default_Role__c' => resource.get('Default_Role__c'), + 'Status__c' => resource.get('Status__c'), 'allocationsByProject' => new Map() }); } @@ -63,7 +69,7 @@ public with sharing class ganttChart { // empty state on resource page if (allocations.isEmpty() && Id.valueOf(recordId).getSobjectType().getDescribe().getName().endsWith('Resource__c')) { - Resource__c resource = [SELECT Id, Name, Active__c, Default_Role__c + Resource__c resource = [SELECT Id, Name, Active__c, Default_Role__c, Status__c FROM Resource__c WHERE Id = :recordId]; @@ -71,11 +77,13 @@ public with sharing class ganttChart { 'Id' => resource.Id, 'Name' => resource.Name, 'Default_Role__c' => resource.Default_Role__c, + 'Status__c' => resource.Status__c, 'allocationsByProject' => new Map() }); } } - + + // organize allocations by resource and project for (Allocation__c allocation : allocations) { if (!resourceById.containsKey(allocation.Resource__c)) { @@ -83,6 +91,7 @@ public with sharing class ganttChart { 'Id' => allocation.Resource__c, 'Name' => allocation.Resource__r.Name, 'Default_Role__c' => allocation.Resource__r.Default_Role__c, + 'Status__c' => allocation.Resource__r.Status__c, 'allocationsByProject' => new Map() }); } @@ -96,7 +105,8 @@ public with sharing class ganttChart { projectById.put(allocation.Project__c, new Map { 'Id' => allocation.Project__c, - 'Name' => allocation.Project__r.Name + 'Name' => allocation.Project__r.Name, + 'Color'=> allocation.Project__r.Color__c }); List projectAllocation = (List)allocationsByProject.get(allocation.Project__c); @@ -120,12 +130,19 @@ public with sharing class ganttChart { }); roles.add(allocation.Resource__r.Default_Role__c); + System.debug('roles' + roles); + //キム追記 + colors.add(allocation.Project__r.Color__c); + System.debug('colors' + colors); } } data.put('projects', projectById.values()); data.put('resources', resourceById.values()); data.put('roles', roles); + System.debug('data.putroles' + roles); + data.put('colors', colors); + System.debug('data.putcolors' + colors); return data; } @@ -134,14 +151,15 @@ public with sharing class ganttChart { public static List getResources() { List resources = new List(); - for (Resource__c r : [SELECT Id, Name, Default_Role__c + for (Resource__c r : [SELECT Id, Name, Default_Role__c, Status__c FROM Resource__c WHERE Active__c = true - ORDER BY Name]) { + ORDER BY Default_Role__c, Name]) { resources.add(new Map { 'Id' => r.Id, 'Name' => r.Name, - 'Default_Role__c' => r.Default_Role__c + 'Default_Role__c' => r.Default_Role__c, + 'Status__c' => r.Status__c }); } @@ -155,6 +173,7 @@ public with sharing class ganttChart { WHERE Active__c = true ORDER BY Name]; } + @AuraEnabled public static void saveAllocation(Id allocationId, Id projectId, Id resourceId, String effort, String status, String startDate, String endDate) { @@ -193,4 +212,19 @@ public with sharing class ganttChart { public static void deleteAllocation(Id allocationId) { delete new Allocation__c(Id = allocationId); } + + + + @AuraEnabled(cacheable=true) + public static List getHolidays() { + List holidays =[SELECT Id, Name,HolidayDate__c + FROM Holidays__c + ]; + return holidays; + } + + + } + + diff --git a/force-app/main/default/classes/tst_ganttChart.cls b/force-app/main/default/classes/tst_ganttChart.cls index 252f87c..ce4a8df 100755 --- a/force-app/main/default/classes/tst_ganttChart.cls +++ b/force-app/main/default/classes/tst_ganttChart.cls @@ -25,8 +25,8 @@ public with sharing class tst_ganttChart { Test.startTest(); Map chartData = ganttChart.getChartData( null, - String.valueOf(dt.getTime()), - String.valueOf(dt.getTime()), + null, + null, 1, new List(), new List(), @@ -78,8 +78,8 @@ public with sharing class tst_ganttChart { Test.startTest(); Map chartData = ganttChart.getChartData( r.Id, - String.valueOf(dt.getTime()), - String.valueOf(dt.getTime()), + null, + null, 1, new List { p.Id }, new List { r.Default_Role__c }, @@ -150,11 +150,14 @@ public with sharing class tst_ganttChart { Default_Role__c='Test Role'); insert r; + Date startDate = Date.newInstance(2023, 3, 1); + Date endDate = Date.newInstance(2023, 3, 10); + String effort = 'High'; String status = 'Active'; Test.startTest(); - ganttChart.saveAllocation(null, p.Id, r.Id, effort, status, String.valueOf(dt.getTime()), String.valueOf(dt.getTime())); + ganttChart.saveAllocation(null, p.Id, r.Id, effort, status, startDate, endDate); Test.stopTest(); List allocations = [SELECT Id, Project__c, Resource__c, Effort__c, Status__c, Start_Date__c, End_Date__c @@ -184,6 +187,9 @@ public with sharing class tst_ganttChart { String effort = 'High'; String status = 'Unavailable'; + Date startDate = Date.newInstance(2023, 3, 1); + Date endDate = Date.newInstance(2023, 3, 10); + Allocation__c a = new Allocation__c( Project__c = p.Id, Resource__c = r.Id, @@ -194,7 +200,7 @@ public with sharing class tst_ganttChart { insert a; Test.startTest(); - ganttChart.saveAllocation(a.Id, null, r.Id, effort, status, String.valueOf(dt.getTime()), String.valueOf(dt.getTime())); + ganttChart.saveAllocation(a.Id, null, r.Id, effort, status, startDate, endDate); Test.stopTest(); List allocations = [SELECT Id, Project__c, Resource__c, Effort__c, Status__c, Start_Date__c, End_Date__c @@ -236,4 +242,19 @@ public with sharing class tst_ganttChart { System.assertEquals(0, allocations.size()); } + + @isTest + static void ganttChart_getHolidays() { + Date d = Date.today(); + Holidays__c h = new Holidays__c( + Name='Test H', + HolidayDate__c = d); + insert h; + + Test.startTest(); + List holidays = ganttChart.getHolidays(); + Test.stopTest(); + + } + } \ No newline at end of file diff --git a/force-app/main/default/layouts/Resource__c-Resource Layout.layout-meta.xml b/force-app/main/default/layouts/Resource__c-Resource Layout.layout-meta.xml index 73306de..fa919b7 100755 --- a/force-app/main/default/layouts/Resource__c-Resource Layout.layout-meta.xml +++ b/force-app/main/default/layouts/Resource__c-Resource Layout.layout-meta.xml @@ -17,6 +17,10 @@ + + Edit + Status__c + Edit OwnerId @@ -63,7 +67,7 @@ false false - 00h9A000000Y26d + 00h6D000002vmrm 4 0 Default diff --git a/force-app/main/default/lwc/gantt_chart/gantt_chart.css b/force-app/main/default/lwc/gantt_chart/gantt_chart.css index bd61401..43cc17f 100755 --- a/force-app/main/default/lwc/gantt_chart/gantt_chart.css +++ b/force-app/main/default/lwc/gantt_chart/gantt_chart.css @@ -15,15 +15,31 @@ } .lwc-timeline_day { - min-width: 50px; + border-bottom: 1px solid #dddbda; + border-right: 1px solid #dddbda; + border-top: 1px solid #dddbda; + width: 50px; text-align: center; - padding-right: 1px; + /* padding-right: 1px; */ } +.lwc-timeline_month-container>div{ + position: sticky; + top: 0; + left: 0; + bottom: 0; + right: 0; + z-index: 1; + + + + +} .lwc-timeline_month-container:first-child .lwc-timeline_day:first-child, .lwc-timeline_month-container:only-child .lwc-timeline_day:first-child { + border-left: 3px solid #dddbda; - + } .lwc-timeline_month-container:last-child .lwc-timeline_day:last-child, @@ -33,7 +49,9 @@ } .lwc-timeline_day.lwc-is-week-end { - border-right: 3px solid #dddbda; + background: rgba(221, 63, 14, 0.1); + border-top: 3px solid #dd2929; + margin-top: 3px; padding-right: 0; } @@ -44,6 +62,11 @@ margin-top: 3px; } +.lwc-timeline_day.lwc-is-holiday { + background: rgba(221, 63, 14, 0.1); + border-top: 3px solid #dd2929; + margin-top: 3px; +} .lwc-timeline_month { border-radius: .25rem; } diff --git a/force-app/main/default/lwc/gantt_chart/gantt_chart.html b/force-app/main/default/lwc/gantt_chart/gantt_chart.html index be8f16b..072e387 100755 --- a/force-app/main/default/lwc/gantt_chart/gantt_chart.html +++ b/force-app/main/default/lwc/gantt_chart/gantt_chart.html @@ -1,4 +1,5 @@ End Mohit's Record Type Search --> - + +
+ +
+ +
+ +
+
onchange={setStatusFilter} >
+ { @@ -108,6 +123,7 @@ export default class GanttChart extends LightningElement { } this.setStartDate(new Date()); this.handleRefresh(); + }); } @@ -119,7 +135,7 @@ export default class GanttChart extends LightningElement { row.closeAllocationMenu(); }); } - + /*** Navigation ***/ setStartDate(_startDate) { if (_startDate instanceof Date && !isNaN(_startDate)) { @@ -127,18 +143,15 @@ export default class GanttChart extends LightningElement { this.datePickerString = _startDate.toISOString(); - this.startDate = moment(_startDate) - .day(1) + this.startDate = moment(_startDate) .toDate(); - this.startDateUTC = - moment(this.startDate) - .utc() - .valueOf() - - moment(this.startDate).utcOffset() * 60 * 1000 + - ""; + //this.startDateUTC = moment(this.startDate).utc().valueOf() - moment(this.startDate).utcOffset() * 60 * 1000 +""; + //console.log(this.startDateUTC); + this.startDateUTC = this.startDate.getTime(); this.formattedStartDate = this.startDate.toLocaleDateString(); - + this.setDateHeaders(); + } else { this.dispatchEvent( new ShowToastEvent({ @@ -149,16 +162,28 @@ export default class GanttChart extends LightningElement { } } + //休日 + @track holidays =[]; + @wire(getHolidays) + wiredGetHolidays({ data, error }) { + if (data) { + //this.holidays = data; + this.holidays = data.map(holiday => holiday.HolidayDate__c); + console.log("holidays" + JSON.stringify(this.holidays)); + this.setDateHeaders(); + } else if (error) { + console.error(error); + } + } + + setDateHeaders() { + this.endDate = moment(this.startDate) .add(this.view.slots * this.view.slotSize - 1, "days") .toDate(); - this.endDateUTC = - moment(this.endDate) - .utc() - .valueOf() - - moment(this.endDate).utcOffset() * 60 * 1000 + - ""; + // this.endDateUTC = moment(this.endDate).utc().valueOf() - moment(this.endDate).utcOffset() * 60 * 1000 +""; + this.endDateUTC = this.endDate.getTime(); this.formattedEndDate = this.endDate.toLocaleDateString(); const dayNames = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]; @@ -179,9 +204,10 @@ export default class GanttChart extends LightningElement { } let day = { + id: "" + date.format("YYYY-MM-DD"), //キムリナ追記 class: "slds-col slds-p-vertical_x-small slds-m-top_x-small lwc-timeline_day", label: date.format("M/D"), - start: date.toDate() + start: date.toDate(), }; if (this.view.slotSize > 1) { @@ -190,8 +216,9 @@ export default class GanttChart extends LightningElement { } else { day.end = date.toDate(); day.dayName = date.format("ddd"); - if (date.day() === 0) { + if (date.day() === 0 || date.day() === 6) { day.class = day.class + " lwc-is-week-end"; + } } @@ -199,6 +226,11 @@ export default class GanttChart extends LightningElement { day.class += " lwc-is-today"; } + //休日のクラス追加 + if (this.holidays.includes(day.id)) { + day.class += " lwc-is-holiday"; + } + //キムリナ追記終了 dates[index].days.push(day); dates[index].style = "width: calc(" + @@ -216,8 +248,10 @@ export default class GanttChart extends LightningElement { ).forEach(resource => { resource.refreshDates(this.startDate, this.endDate, this.view.slotSize); }); + } + navigateToToday() { this.setStartDate(new Date()); this.handleRefresh(); @@ -240,14 +274,14 @@ export default class GanttChart extends LightningElement { } navigateToDay(event) { - this.setStartDate(new Date(event.target.value + "T00:00:00")); + this.setStartDate(new Date(event.target.value)); this.handleRefresh(); } setView(value) { let values = value.split("/"); this.view.value = value; - this.view.slotSize = parseInt(value[0], 10); + this.view.slotSize = parseInt(values[0], 10); this.view.slots = parseInt(values[1], 10); } @@ -348,8 +382,17 @@ export default class GanttChart extends LightningElement { [], this._filterData.projects ); + console.log("this.filterModalData.projects"+JSON.stringify(this.filterModalData.projects) ); + this.filterModalData.colors = Object.assign( + [], + this._filterData.colors + ); + console.log("this.filterModalData.colors "+JSON.stringify(this._filterData.colors) ); + this.filterModalData.roles = Object.assign([], this._filterData.roles); this.filterModalData.status = this._filterData.status; + + this.template.querySelector(".filter-modal").show(); } @@ -371,7 +414,9 @@ export default class GanttChart extends LightningElement { }); this.filterModalData.focus = "projects"; }); + console.log("projects"+JSON.stringify(this.projects) ); } + // Mohit's filter by record type filterProjectRecords(event) { this.hideDropdowns(); @@ -399,6 +444,7 @@ export default class GanttChart extends LightningElement { this.filterModalData.focus = null; this.setFilterModalDataDisable(); + console.log("filterModalData"+JSON.stringify(this.filterModalData.projects) ); } // Mohit's addProjectRecordTypeFilter @@ -434,9 +480,13 @@ export default class GanttChart extends LightningElement { .map(role => { return role; }); + this.filterModalData.focus = "roles"; + console.log("roles"+JSON.stringify(this.roles) ); + } + addRoleFilter(event) { this.filterModalData.roles.push(event.currentTarget.dataset.role); this.filterModalData.focus = null; @@ -453,8 +503,48 @@ export default class GanttChart extends LightningElement { this.setFilterModalDataDisable(); } + //キム追記 + // filterColors,addColorFilter,removeColorFilterメゾット + filterColors(event){ + this.hideDropdowns(); + + let text = event.target.value; + + // only show roles not selected + this.filterModalData.colorOptions = this.colors + .filter(color => { + return ( + color.toLowerCase().includes(text.toLowerCase()) && + !this.filterModalData.colors.filter(c => { + return c === color; + }).length + ); + }) + .map(color => { + return color; + }); + + this.filterModalData.focus = "colors"; + console.log("colors"+JSON.stringify(this.colors) ); + + } + + addColorFilter(event){ + this.filterModalData.colors.push(event.currentTarget.dataset.color); + this.filterModalData.focus = null; + this.setFilterModalDataDisable(); + + } + + removeColorFilter(event){ + this.filterModalData.colors.splice(event.currentTarget.dataset.index, 1); + this.setFilterModalDataDisable(); + } + //キム追記終了 + clearFilters() { this.filterModalData.projects = []; + this.filterModalData.colors = []; this.filterModalData.roles = []; this.filterModalData.status = ""; this.filterModalData.disabled = true; @@ -465,6 +555,7 @@ export default class GanttChart extends LightningElement { if ( this.filterModalData.projects.length > 0 || + this.filterModalData.colors.length > 0 || this.filterModalData.roles.length > 0 || this.filterModalData.status !== "" ) { @@ -477,12 +568,14 @@ export default class GanttChart extends LightningElement { if (this.filterModalData.focus) { return; } + this.filterModalData.colorOptions = []; this.filterModalData.projectOptions = []; this.filterModalData.roleOptions = []; } applyFilters() { this._filterData = { + colors: Object.assign([], this.filterModalData.colors), projects: Object.assign([], this.filterModalData.projects), roles: Object.assign([], this.filterModalData.roles), status: this.filterModalData.status @@ -491,143 +584,91 @@ export default class GanttChart extends LightningElement { this._filterData.projectIds = this._filterData.projects.map(project => { return project.id; }); - /* - this._filterData.projectRecordType = this._filterData.projects.map(project => { - return project.recordTypeId; - }); -*/ + let filters = []; + if (this.filterModalData.colors.length) { + filters.push("Colors"); + } if (this.filterModalData.projects.length) { filters.push("Projects"); } - /* - if (this.filterModalData.projectRecordType.length) { - filters.push("projectRecordTypes"); - } - */ + if (this.filterModalData.roles.length) { filters.push("Roles"); } if (this.filterModalData.status) { filters.push("Status"); } - if (this.filterModalData.status) { - filters.push("Status"); - } - + if (filters.length) { this._filterData.message = "Filtered By " + filters.join(", "); } - + this.handleRefresh(); this.template.querySelector(".filter-modal").hide(); } - /*** /Filter Modal ***/ - - // @wire(getChartData, { - // recordId: "$recordId", - // startTime: "$startDateUTC", - // endTime: "$endDateUTC", - // slotSize: "$view.slotSize", - // filterProjects: "$_filterData.projectIds", - // filterRoles: "$_filterData.roles", - // filterStatus: "$_filterData.status" - // }) - // wiredChartData(value) { - // const {error, data} = value; - // this.wiredData = value; - - // if (data) { - // this.isResourceView = - // typeof this.objectApiName !== "undefined" && - // this.objectApiName.endsWith("Resource__c"); - // this.isProjectView = - // typeof this.objectApiName !== "undefined" && - // this.objectApiName.endsWith("Project__c"); - // this.projectId = data.projectId; - // this.projects = data.projects; - // this.roles = data.roles; - - // // empty old data - // // we want to keep resources we've already seen - // this.resources.forEach((resource, i) => { - // this.resources[i] = { - // Id: resource.Id, - // Name: resource.Name, - // Default_Role__c: resource.Default_Role__c, - // allocationsByProject: {} - // }; - // }); - - // data.resources.forEach(newResource => { - // for (let i = 0; i < this.resources.length; i++) { - // if (this.resources[i].Id === newResource.Id) { - // this.resources[i] = newResource; - // return; - // } - // } - - // this.resources.push(newResource); - // }); - // } else if (error) { - // this.dispatchEvent( - // new ShowToastEvent({ - // message: error.message, - // variant: "error" - // }) - // ); - // } - // } - + handleRefresh() { // refreshApex(this.wiredData); let self = this; getChartData({ - recordId: self.recordId ? self.recordId : '', - startTime: self.startDateUTC, - endTime: self.endDateUTC, - slotSize: self.view.slotSize, - filterProjects: self._filterData.projectIds, - filterProjectRecords: self._filterData.projectRecordTypes, // filter for record types - filterRoles: self._filterData.roles, - filterStatus: self._filterData.status - }).then(data => { - self.isResourceView = typeof self.objectApiName !== 'undefined' && self.objectApiName.endsWith('Resource__c'); - self.isProjectView = typeof self.objectApiName !== 'undefined' && self.objectApiName.endsWith('Project__c'); - self.isRecordTypeView = typeof self.objectApiName !== 'undefined' && self.objectApiName.endsWith('Project__c'); - self.projectId = data.projectId; - self.projects = data.projects; - self.roles = data.roles; - - // empty old data - // we want to keep resources we've already seen - self.resources.forEach(function (resource, i) { - self.resources[i] = { - Id: resource.Id, - Name: resource.Name, - Default_Role__c: resource.Default_Role__c, - allocationsByProject: {} - }; - }); + recordId: self.recordId ? self.recordId : '', + startTime: self.startDateUTC, + endTime: self.endDateUTC, + slotSize: self.view.slotSize, + filterColors: self._filterData.colors, + filterProjects: self._filterData.projectIds, + filterProjectRecords: self._filterData.projectRecordTypes, // filter for record types + filterRoles: self._filterData.roles, + filterStatus: self._filterData.status + }).then(data => { + self.isResourceView = typeof self.objectApiName !== 'undefined' && self.objectApiName.endsWith('Resource__c'); + self.isProjectView = typeof self.objectApiName !== 'undefined' && self.objectApiName.endsWith('Project__c'); + self.isRecordTypeView = typeof self.objectApiName !== 'undefined' && self.objectApiName.endsWith('Project__c'); + self.colors =data.colors; + self.projectId = data.projectId; + self.projects = data.projects; + self.roles = data.roles; + + // empty old data + // we want to keep resources we've already seen + self.resources.forEach(function (resource, i) { + self.resources[i] = { + Id: resource.Id, + Name: resource.Name, + Default_Role__c: resource.Default_Role__c, + allocationsByProject: {} + }; + + }); - data.resources.forEach(function (newResource) { - for (let i = 0; i < self.resources.length; i++) { - if (self.resources[i].Id === newResource.Id) { - self.resources[i] = newResource; - return; - } - } + data.resources.forEach(function (newResource) { + for (let i = 0; i < self.resources.length; i++) { + if (self.resources[i].Id === newResource.Id) { + self.resources[i] = newResource; + return; + } + } self.resources.push(newResource); }); + if (applyFilter && (self._filterData.colors != "" || self._filterData.projectIds != "" || self._filterData.roles != "" || self._filterData.status != "")) { + self.resources = self.resources.filter(resource => JSON.stringify(resource.allocationsByProject) !== '{}'); + } + debugger; + }).catch(error => { this.dispatchEvent(new ShowToastEvent({ message: error.body.message, variant: 'error' })); }); + } -} + + + +} \ No newline at end of file diff --git a/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.css b/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.css index e2b34e3..8bcc9bf 100755 --- a/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.css +++ b/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.css @@ -121,15 +121,24 @@ cursor: pointer; min-width: 50px; transition: background-color 200ms ease 0s; + } .lwc-timeslot:first-child { border-left: 3px solid #dddbda; + } -.lwc-timeslot.lwc-is-week-end, .lwc-timeslot:last-child { border-right: 3px solid #dddbda; + +} +.lwc-timeslot.lwc-is-week-end{ + background: rgba(221, 63, 14, 0.1); +} + +.lwc-timeslot.lwc-is-holiday{ + background: rgba(221, 63, 14, 0.1); } .lwc-timeslot:hover { diff --git a/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.html b/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.html index 258a3be..3ba6afd 100755 --- a/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.html +++ b/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.html @@ -4,7 +4,7 @@
- +

@@ -13,6 +13,9 @@

{resource.Default_Role__c}

+

+ {resource.Status__c} +

@@ -111,6 +114,8 @@

Add Allocation
+ diff --git a/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.js b/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.js index 184c8a1..f16314d 100755 --- a/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.js +++ b/force-app/main/default/lwc/gantt_chart_resource/gantt_chart_resource.js @@ -1,11 +1,14 @@ -import { LightningElement, api, track } from "lwc"; +import { LightningElement, api, track, wire} from "lwc"; import { ShowToastEvent } from "lightning/platformShowToastEvent"; +import {NavigationMixin} from 'lightning/navigation'; + import getProjects from "@salesforce/apex/ganttChart.getProjects"; import saveAllocation from "@salesforce/apex/ganttChart.saveAllocation"; import deleteAllocation from "@salesforce/apex/ganttChart.deleteAllocation"; +import getHolidays from "@salesforce/apex/ganttChart.getHolidays"; -export default class GanttChartResource extends LightningElement { +export default class GanttChartResource extends NavigationMixin(LightningElement) { @api isResourceView; // resource page has different layout @api projectId; // used on project page for quick adding of allocations @api @@ -16,12 +19,35 @@ export default class GanttChartResource extends LightningElement { this._resource = _resource; this.setProjects(); } - +  // dates @api startDate; @api endDate; @api dateIncrement; - + // IconType + @api iconType; + @api backgroundColor; + + @api formatDate(dt) { + var y = dt.getFullYear(); + var m = ('00' + (dt.getMonth()+1)).slice(-2); + var d = ('00' + dt.getDate()).slice(-2); + return (y + '-' + m + '-' + d); + } + //休日 + @api holidays =[]; + @wire(getHolidays) + wiredGetHolidays({ data, error }) { + console.log('data:', data); + console.log('error:', error); + if (data) { + this.holidays = data.map(holiday => holiday.HolidayDate__c); + console.log("holidays" + JSON.stringify(this.holidays)); + this.refreshDates(this.startDate, this.endDate, this.dateIncrement); + } else if (error) { + console.error(error); + } + } @api refreshDates(startDate, endDate, dateIncrement) { if (startDate && endDate && dateIncrement) { @@ -36,6 +62,7 @@ export default class GanttChartResource extends LightningElement { date.setDate(date.getDate() + dateIncrement) ) { let time = { + id: ""+ this.formatDate(date),//キムリナ追記 class: "slds-col lwc-timeslot", start: date.getTime() }; @@ -47,7 +74,7 @@ export default class GanttChartResource extends LightningElement { } else { time.end = date.getTime(); - if (times.length % 7 === 6) { + if (times.length % 7 === 6 || times.length %7 === 5) { time.class += " lwc-is-week-end"; } } @@ -55,6 +82,11 @@ export default class GanttChartResource extends LightningElement { if (today >= time.start && today <= time.end) { time.class += " lwc-is-today"; } + + if (this.holidays.includes(time.id)) { + time.class += " lwc-is-holiday"; + } + //キムりな追記終了 times.push(time); } @@ -63,6 +95,15 @@ export default class GanttChartResource extends LightningElement { this.startDate = startDate; this.endDate = endDate; this.dateIncrement = dateIncrement; + + //set IconType + switch( this._resource.Default_Role__c){ + case 'エンジニア': this.iconType = 'standard:user'; break; + case '車': this.iconType = 'standard:work_order'; break; + case 'ケーブル': this.iconType = 'standard:apex_plugin'; break; + case 'ツール': this.iconType = 'standard:custom'; break; + default: this.iconType = 'utility:question_mark'; break; + } this.setProjects(); } } @@ -119,7 +160,10 @@ export default class GanttChartResource extends LightningElement { ]; connectedCallback() { - this.refreshDates(this.startDate, this.endDate, this.dateIncrement); + + + this.refreshDates(this.startDate, this.endDate, this.dateIncrement); + } // calculate allocation classes @@ -237,11 +281,12 @@ export default class GanttChartResource extends LightningElement { }; self.resource.allocationsByProject[projectId].forEach(allocation => { - allocation.class = self.calcClass(allocation); - allocation.style = self.calcStyle(allocation); - allocation.labelStyle = self.calcLabelStyle(allocation); + let _allocation = Object.assign({}, allocation); + _allocation.class = self.calcClass(_allocation); + _allocation.style = self.calcStyle(_allocation); + _allocation.labelStyle = self.calcLabelStyle(_allocation); - project.allocations.push(allocation); + project.allocations.push(_allocation); }); self.projects.push(project); @@ -251,9 +296,12 @@ export default class GanttChartResource extends LightningElement { handleTimeslotClick(event) { const start = new Date(parseInt(event.currentTarget.dataset.start, 10)); const end = new Date(parseInt(event.currentTarget.dataset.end, 10)); - const startUTC = start.getTime() + start.getTimezoneOffset() * 60 * 1000; - const endUTC = end.getTime() + end.getTimezoneOffset() * 60 * 1000; - + // const startUTC = start.getTime() + start.getTimezoneOffset() * 60 * 1000; + // const endUTC = end.getTime() + end.getTimezoneOffset() * 60 * 1000; +const startUTC = start.getTime(); +const endUTC = end.getTime(); + console.log(start); + console.log(end); if (this.projectId) { this._saveAllocation({ startDate: startUTC + "", @@ -275,6 +323,11 @@ export default class GanttChartResource extends LightningElement { label: "Unavailable" }); + projects.push( { + value: "Create", + label: "+新規作成" + }) + self.addAllocationData = { projects: projects, startDate: startUTC + "", @@ -301,6 +354,16 @@ export default class GanttChartResource extends LightningElement { if (!this.addAllocationData.projectId) { this.addAllocationData.disabled = true; } else { + if( event.target.value === 'Create'){ + + this[NavigationMixin.Navigate]({ + type: 'standard__objectPage', + attributes: { + objectApiName: 'Project__c', + actionName: 'new' + } + }) + } this.addAllocationData.disabled = false; } } @@ -364,6 +427,7 @@ export default class GanttChartResource extends LightningElement { }); } + /*** Drag/Drop ***/ dragInfo = {}; handleDragStart(event) { @@ -375,7 +439,9 @@ export default class GanttChartResource extends LightningElement { this.dragInfo.newAllocation = this.projects[ container.dataset.project ].allocations[container.dataset.allocation]; - + console.log(" this.dragInfo.projectIndex"+ JSON.stringify( this.dragInfo.projectIndex) ); + console.log("this.dragInfo.allocationIndex"+ JSON.stringify(this.dragInfo.allocationIndex) ); + console.log(" this.dragInfo.newAllocation"+ JSON.stringify( this.dragInfo.newAllocation) ); // hide drag image container.style.opacity = 0; setTimeout(function() { @@ -408,10 +474,11 @@ export default class GanttChartResource extends LightningElement { this._saveAllocation({ allocationId: allocation.Id, - startDate: - startDate.getTime() + startDate.getTimezoneOffset() * 60 * 1000 + "", - endDate: endDate.getTime() + endDate.getTimezoneOffset() * 60 * 1000 + "" + startDate:startDate.getTime() + "", + endDate: endDate.getTime() + "" }); + console.log("startDate"+ JSON.stringify(startDate) ); + console.log("endDate"+ JSON.stringify(endDate) ); this.dragInfo = {}; this.template.querySelector( @@ -438,7 +505,8 @@ export default class GanttChartResource extends LightningElement { switch (direction) { case "left": if (index <= allocation.right) { - allocation.Start_Date__c = start.toJSON().substr(0, 10); + // allocation.Start_Date__c = start.toJSON().substr(0, 10); + allocation.Start_Date__c = moment(start).format('YYYY-MM-DD'); allocation.left = index; } else { allocation = this.dragInfo.newAllocation; @@ -446,7 +514,8 @@ export default class GanttChartResource extends LightningElement { break; case "right": if (index >= allocation.left) { - allocation.End_Date__c = end.toJSON().substr(0, 10); + // allocation.End_Date__c = end.toJSON().substr(0, 10); + allocation.End_Date__c = moment(end).format('YYYY-MM-DD'); allocation.right = index; } else { allocation = this.dragInfo.newAllocation; @@ -468,8 +537,10 @@ export default class GanttChartResource extends LightningElement { endDate.getDate() + allocation.right * this.dateIncrement ); - allocation.Start_Date__c = startDate.toJSON().substr(0, 10); - allocation.End_Date__c = endDate.toJSON().substr(0, 10); + // allocation.Start_Date__c = startDate.toJSON().substr(0, 10); + // allocation.End_Date__c = endDate.toJSON().substr(0, 10); + allocation.Start_Date__c = moment(startDate).format('YYYY-MM-DD'); + allocation.End_Date__c = moment(endDate).format('YYYY-MM-DD'); } this.dragInfo.newAllocation = allocation; @@ -553,14 +624,12 @@ export default class GanttChartResource extends LightningElement { editAllocationModalSuccess() { const startDate = new Date(this.editAllocationData.startDate + "T00:00:00"); const endDate = new Date(this.editAllocationData.endDate + "T00:00:00"); - + this._saveAllocation({ allocationId: this.editAllocationData.id, projectId: this.editAllocationData.projectId, - startDate: - startDate.getTime() + startDate.getTimezoneOffset() * 60 * 1000 + "", - endDate: - endDate.getTime() + startDate.getTimezoneOffset() * 60 * 1000 + "", + startDate:startDate.getTime() + "", + endDate: endDate.getTime() + "", effort: this.editAllocationData.effort, status: this.editAllocationData.status }) @@ -608,4 +677,6 @@ export default class GanttChartResource extends LightningElement { ); }); } + + } diff --git a/force-app/main/default/objects/Project__c/listViews/All.listView-meta.xml b/force-app/main/default/objects/Project__c/listViews/All.listView-meta.xml new file mode 100644 index 0000000..f957a40 --- /dev/null +++ b/force-app/main/default/objects/Project__c/listViews/All.listView-meta.xml @@ -0,0 +1,7 @@ + + + All + NAME + Everything + + diff --git a/force-app/main/default/objects/Resource__c/fields/Status__c.field-meta.xml b/force-app/main/default/objects/Resource__c/fields/Status__c.field-meta.xml new file mode 100644 index 0000000..6b7e984 --- /dev/null +++ b/force-app/main/default/objects/Resource__c/fields/Status__c.field-meta.xml @@ -0,0 +1,31 @@ + + + Status__c + "普通" + false + + false + false + Picklist + + true + + false + + + false + + + + 普通 + false + + + + 悪い + false + + + + + diff --git a/force-app/main/default/objects/Resource__c/listViews/All.listView-meta.xml b/force-app/main/default/objects/Resource__c/listViews/All.listView-meta.xml new file mode 100644 index 0000000..d636158 --- /dev/null +++ b/force-app/main/default/objects/Resource__c/listViews/All.listView-meta.xml @@ -0,0 +1,9 @@ + + + All + NAME + Default_Role__c + Status__c + Everything + + diff --git a/force-app/main/default/profiles/Admin.profile-meta.xml b/force-app/main/default/profiles/Admin.profile-meta.xml index 7c8e55c..012ed73 100755 --- a/force-app/main/default/profiles/Admin.profile-meta.xml +++ b/force-app/main/default/profiles/Admin.profile-meta.xml @@ -327,10 +327,6 @@ true ExportReport - - true - FieldServiceAccess - true GiveRecognitionBadge @@ -583,10 +579,6 @@ true SelectFilesFromSalesforce - - true - SendExternalEmailAvailable - true SendSitRequests diff --git a/force-app/main/default/reportTypes/Resrouce.reportType-meta.xml b/force-app/main/default/reportTypes/Resrouce.reportType-meta.xml new file mode 100644 index 0000000..9c65a5b --- /dev/null +++ b/force-app/main/default/reportTypes/Resrouce.reportType-meta.xml @@ -0,0 +1,123 @@ + + + Resource__c + other + false + Resource(Allocationの有無を問わない) + + true + Allocations__r + + + + + false + Id + Resource__c
+
+ + false + Owner + Resource__c
+
+ + true + Name + Resource__c
+
+ + false + CreatedDate + Resource__c
+
+ + false + CreatedBy + Resource__c
+
+ + false + LastModifiedDate + Resource__c
+
+ + false + LastModifiedBy + Resource__c
+
+ + false + Active__c + Resource__c
+
+ + false + Default_Role__c + Resource__c
+
+ + false + Status__c + Resource__c
+
+ Resources +
+ + + false + Id + Resource__c.Allocations__r
+
+ + true + Name + Resource__c.Allocations__r
+
+ + false + CreatedDate + Resource__c.Allocations__r
+
+ + false + CreatedBy + Resource__c.Allocations__r
+
+ + false + LastModifiedDate + Resource__c.Allocations__r
+
+ + false + LastModifiedBy + Resource__c.Allocations__r
+
+ + false + Effort__c + Resource__c.Allocations__r
+
+ + false + End_Date__c + Resource__c.Allocations__r
+
+ + false + Project__c + Resource__c.Allocations__r
+
+ + false + Start_Date__c + Resource__c.Allocations__r
+
+ + false + Status__c + Resource__c.Allocations__r
+
+ Allocations +
+