Skip to content

Commit

Permalink
Make it possible to work with draft and published versions of project…
Browse files Browse the repository at this point in the history
… status reports #119
  • Loading branch information
olemp committed Dec 16, 2019
1 parent 30760eb commit f6ea470
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 5 deletions.
4 changes: 4 additions & 0 deletions SharePointFramework/@Shared/src/models/StatusReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class StatusReport {
return this._item.FieldValuesAsText || this._item;
}

public get moderationStatus(): string {
return this._item.FieldValuesAsText.GtModerationStatus;
}

/**
* Get status values from item
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class PortalDataService {
* @param {TypedHash<string>} properties Properties
*/
public async updateStatusReport(id: number, properties: TypedHash<string>): Promise<void> {
await this._web.lists.getByTitle(this._configuration.listNames.STATUS_SECTIONS).items.getById(id).update(properties);
await this._web.lists.getByTitle(this._configuration.listNames.PROJECT_STATUS).items.getById(id).update(properties);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion SharePointFramework/PortfolioWebParts/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class DataAdapter {
}),
sp.search({
...DEFAULT_SEARCH_SETTINGS,
QueryTemplate: `DepartmentId:{${siteId}} ContentTypeId:0x010022252E35737A413FB56A1BA53862F6D5*`,
QueryTemplate: `DepartmentId:{${siteId}} ContentTypeId:0x010022252E35737A413FB56A1BA53862F6D5* GtModerationStatusOWSCHCS:Publisert`,
SelectProperties: [...configuration.columns.map(f => f.fieldName), siteIdProperty],
Refiners: configuration.refiners.map(ref => ref.fieldName).join(','),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ export class ProjectStatus extends React.Component<IProjectStatusProps, IProject
name: strings.EditReportButtonText,
iconProps: { iconName: 'Edit' },
href: selectedReport ? selectedReport.editFormUrl : null,
disabled: !selectedReport,
disabled: !selectedReport || selectedReport.moderationStatus === strings.GtModerationStatus_Choice_Published,
},
{
id: getId('PublishReport'),
key: getId('PublishReport'),
name: strings.PublishReportButtonText,
iconProps: { iconName: 'PublishContent' },
disabled: !selectedReport || selectedReport.moderationStatus === strings.GtModerationStatus_Choice_Published,
onClick: _ => { this._publishReport(selectedReport); },
},
];
let farItems: IContextualMenuItem[] = [];
Expand Down Expand Up @@ -274,11 +282,22 @@ export class ProjectStatus extends React.Component<IProjectStatusProps, IProject
Logger.log({ message: '(ProjectStatus) _redirectNewStatusReport: Copying budget numbers from previous report', data: { id: previousReport.id, budgetNumbers: previousReport.budgetNumbers }, level: LogLevel.Info });
properties = { ...properties, ...previousReport.budgetNumbers };
}
properties.GtModerationStatus = strings.GtModerationStatus_Choice_Draft;
Logger.log({ message: '(ProjectStatus) _redirectNewStatusReport: Created new status report', data: { properties }, level: LogLevel.Info });
const newReportId = await this._portalDataService.addStatusReport(properties);
document.location.href = `${window.location.protocol}//${window.location.hostname}${this.state.data.reportEditFormUrl}?ID=${newReportId}&Source=${encodeURIComponent(window.location.href)}`;
}

/**
* Publish report
*
* @param {StatusReport} report Report
*/
private async _publishReport(report: StatusReport) {
await this._portalDataService.updateStatusReport(report.id, { GtModerationStatus: strings.GtModerationStatus_Choice_Published });
document.location.reload();
}

/**
* Fetch data
*/
Expand Down
3 changes: 3 additions & 0 deletions SharePointFramework/ProjectWebParts/src/loc/mystrings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ declare interface IProjectWebPartsStrings {
DocumentsListName: string;
EditPropertiesText: string;
EditReportButtonText: string;
PublishReportButtonText: string;
EditSiteInformationText: string;
ErrorText: string;
ListSectionDataErrorMessage: string;
Expand Down Expand Up @@ -87,6 +88,8 @@ declare interface IProjectWebPartsStrings {
RiskMatrix_ViewSelectorLabel: string;
RiskMatrix_EmptyMessage: string;
RiskMatrix_LoadingText: string;
GtModerationStatus_Choice_Published: string;
GtModerationStatus_Choice_Draft: string;
}

declare module 'ProjectWebPartsStrings' {
Expand Down
5 changes: 4 additions & 1 deletion SharePointFramework/ProjectWebParts/src/loc/nb-no.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ define([], function () {
DocumentsListName: 'Dokumenter',
EditPropertiesText: 'Rediger egenskaper',
EditReportButtonText: 'Rediger status',
PublishReportButtonText: 'Publiser',
EditSiteInformationText: 'Rediger områdeinformasjon',
ErrorText: 'Det skjedde en feil under lasting av {0}.',
ListSectionDataErrorMessage: 'Det skjedde en feil under uthenting av data for seksjonen. Er den riktig konfigurert?',
Expand Down Expand Up @@ -87,6 +88,8 @@ define([], function () {
RiskMatrix_Header_VeryLow: 'Svart lav',
RiskMatrix_ViewSelectorLabel: 'Velg en visning',
RiskMatrix_EmptyMessage: 'Det finnes ingen Risiko-elementer i den angitte visningen.',
RiskMatrix_LoadingText: 'Laster risikomatrise...'
RiskMatrix_LoadingText: 'Laster risikomatrise...',
GtModerationStatus_Choice_Published: 'Publisert',
GtModerationStatus_Choice_Draft: 'Kladd'
}
});
3 changes: 2 additions & 1 deletion Templates/Portfolio/Objects/ContentTypes/Prosjektstatus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<pnp:FieldRef ID="b5932b1d-bee4-410c-aac2-54a7cd9d5381" Name="GtStatusRiskComment" />
<pnp:FieldRef ID="b1958607-cd56-4ecb-9ad7-65fb7d3c22c7" Name="GtStatusGainAchievement" Required="true" />
<pnp:FieldRef ID="cb41572a-78c6-4e33-8505-b97bfd8fd162" Name="GtStatusGainAchievementComment" />
<pnp:FieldRef ID="9a81b4e1-64ea-40c2-9be1-946f20e78999" Name="GtModerationStatus" />
<pnp:FieldRef ID="fba7ced6-9970-4b14-ab9c-7c809310d86d" Name="GtSiteId" />
</pnp:FieldRefs>
</pnp:ContentType>
</pnp:ContentType>
1 change: 1 addition & 0 deletions Templates/Portfolio/Objects/SiteFields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Objects/SiteFields/GtStatusTimeComment.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Objects/SiteFields/GtValue.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Objects/SiteFields/GtProjectLifecycleStatus.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Objects/SiteFields/GtModerationStatus.xml" />
</pnp:SiteFields>
7 changes: 7 additions & 0 deletions Templates/Portfolio/Objects/SiteFields/GtModerationStatus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Field ID="{9a81b4e1-64ea-40c2-9be1-946f20e78999}" Name="GtModerationStatus" DisplayName="Status" Type="Choice" Group="Kolonner for Prosjektportalen (PrPorteføljeosjekt)" Description="" FillInChoice="FALSE" StaticName="GtModerationStatus" ShowInEditForm="FALSE" ShowInNewForm="FALSE">
<Default>Kladd</Default>
<CHOICES>
<CHOICE>Kladd</CHOICE>
<CHOICE>Publisert</CHOICE>
</CHOICES>
</Field>

0 comments on commit f6ea470

Please sign in to comment.