Skip to content

Commit

Permalink
Fix problem creating columns from PortfolioOverview webpart (Program)…
Browse files Browse the repository at this point in the history
… [skip-ci]
  • Loading branch information
Remi749 committed Jan 22, 2024
1 parent 079d79a commit a6e30e0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function useColumnFormPanel() {
* If the column is being edited, it will update the column in the list
* using `updateItemInList` from the `dataAdapter`. If the column is new,
* it will add the column to the list using `addColumnToPortfolioView` from
* the `dataAdapter`.
* the shared `dataAdapter`.
*/
const onSave = async () => {
const colummData = column.get('data') ?? {}
Expand Down Expand Up @@ -61,7 +61,7 @@ export function useColumnFormPanel() {
_.omit(columnItem, ['Id', 'GtInternalName', 'GtManagedProperty'])
)
} else {
await context.props.dataAdapter.addColumnToPortfolioView(
await context.props.dataAdapter.portalDataService.addColumnToPortfolioView(
columnItem,
context.state.currentView
)
Expand Down
19 changes: 0 additions & 19 deletions SharePointFramework/PortfolioWebParts/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,25 +763,6 @@ export class DataAdapter implements IPortfolioWebPartsDataAdapter {
throw new Error(format(strings.DataSourceCategoryError, category))
}
}



public async addColumnToPortfolioView(
properties: SPProjectColumnItem,
view: PortfolioOverviewView
): Promise<boolean> {
try {
const projectColumnsList = this._sp.web.lists.getByTitle(strings.ProjectColumnsListName)
const portfolioViewsList = this._sp.web.lists.getByTitle(strings.PortfolioViewsListName)
const column = await projectColumnsList.items.add(_.omit(properties, ['Id']))
portfolioViewsList.items.getById(view.id as any).update({
GtPortfolioColumnsId: [...view.columns.map((c) => c.id), column.data.Id]
})
return true
} catch (error) {
return false
}
}
}

export * from './types'
10 changes: 5 additions & 5 deletions SharePointFramework/PortfolioWebParts/src/data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ export interface IPortfolioWebPartsDataAdapter {
): Promise<any[]>

/**
* Adds a new column to the project columns list and adds the column to the specified view.
* Adds a new column to the project content columns list and adds the column to the specified data source.
*
* @param properties Properties for the new column (`Id` will be omitted)
* @param view The view to add the column to
* @param dataSource The data source to add the column to
*/
addColumnToPortfolioView?(
properties: SPProjectColumnItem,
view: PortfolioOverviewView
addColumnToDataSource?(
properties: SPProjectContentColumnItem,
dataSource: DataSource
): Promise<boolean>
}
7 changes: 6 additions & 1 deletion SharePointFramework/ProgramWebParts/src/loc/mystrings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ declare interface IProgramWebPartsStrings {
InternalNameLabel: string
IsGroupableDescription: string
IsGroupableLabel: string
IsRefinableDescription: string
IsRefinableLabel: string
IsResizableLabel: string
ListViewText: string
MaxWidthDescription: string
MaxWidthLabel: string
Expand Down Expand Up @@ -153,6 +156,9 @@ declare interface IProgramWebPartsStrings {
SearchQueryLabel: string
ShowCommandBarLabel: string
ShowExcelExportButtonLabel: string
ShowFieldFrontpageLabel: string
ShowFieldPortfolioLabel: string
ShowFieldProjectStatusLabel: string
ShowFiltersLabel: string
ShowGroupByLabel: string
ShowHideColumnsLabel: string
Expand All @@ -169,7 +175,6 @@ declare interface IProgramWebPartsStrings {
ToggleEditViewColumnsLabel: string
UseChangesButtonText: string
ViewNotFoundMessage: string

DataSourceItemNotFound: string
DataSourceListName: string
ProjectContentColumnItemNotFound: string
Expand Down
6 changes: 6 additions & 0 deletions SharePointFramework/ProgramWebParts/src/loc/nb-no.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ define([], function () {
InternalNameLabel: 'Internt feltnavn',
IsGroupableDescription: 'Brukere kan gruppere på denne kolonnen.',
IsGroupableLabel: 'Grupperbar',
IsRefinableDescription: 'Brukere kan filtrere på denne kolonnen.',
IsRefinableLabel: 'Presiser',
IsResizableLabel: 'Justerbar',
ListViewText: 'Liste',
MaxWidthDescription: 'Maksimum bredde for kolonnen. Kan ikke være mindre enn minimum bredde.',
MaxWidthLabel: 'Maks bredde',
Expand Down Expand Up @@ -154,6 +157,9 @@ define([], function () {
SearchQueryLabel: 'Søkespørring',
ShowCommandBarLabel: 'Vis kommandolinje',
ShowExcelExportButtonLabel: 'Vis eksport til Excel-knapp',
ShowFieldFrontpageLabel: 'Prosjektforside',
ShowFieldPortfolioLabel: 'Porteføljeoversikt',
ShowFieldProjectStatusLabel: 'Prosjektstatus',
ShowFiltersLabel: 'Vis filtre',
ShowGroupByLabel: 'Vis grupperingsvalg',
ShowHideColumnsLabel: 'Vis eller skjul kolonner',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,29 @@ export class PortalDataService extends DataService<IPortalDataServiceConfigurati
return spItems.map((item) => new ProjectColumnConfig(item))
}

/**
* Adds a new column to the project columns list and adds the column to the specified view.
*
* @param properties Properties for the new column (`Id` will be omitted)
* @param view The view to add the column to
*/
public async addColumnToPortfolioView(
properties: SPProjectColumnItem,
view: PortfolioOverviewView
): Promise<boolean> {
try {
const projectColumnsList = this._getList('PROJECT_COLUMNS')
const portfolioViewsList = this._getList('PORTFOLIO_VIEWS')
const column = await projectColumnsList.items.add(_.omit(properties, ['Id']))
portfolioViewsList.items.getById(view.id as any).update({
GtPortfolioColumnsId: [...view.columns.map((c) => c.id), column.data.Id]
})
return true
} catch (error) {
return false
}
}

/**
* Get portfolio overview views. Returns all shared views and personal views.
*/
Expand Down

0 comments on commit a6e30e0

Please sign in to comment.