Aktualisiere Versionsnummern auf 1.0.4 in package.json, package-solution.json, Manifestdateien und verbessere Fehlerbehandlung in RestError.ts; füge OData-Version zu Headern in ExpiryItemService.ts und ExpiryConfigService.ts hinzu.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"solution": {
|
"solution": {
|
||||||
"name": "expiry-indicator-client-side-solution",
|
"name": "expiry-indicator-client-side-solution",
|
||||||
"id": "68bb6d2d-9895-45b4-88e8-b98835faa981",
|
"id": "68bb6d2d-9895-45b4-88e8-b98835faa981",
|
||||||
"version": "1.0.3.0",
|
"version": "1.0.4.0",
|
||||||
"includeClientSideAssets": true,
|
"includeClientSideAssets": true,
|
||||||
"skipFeatureDeployment": false,
|
"skipFeatureDeployment": false,
|
||||||
"features": [
|
"features": [
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"title": "ExpiryIndicator command set registration",
|
"title": "ExpiryIndicator command set registration",
|
||||||
"description": "Registers ExpiryIndicator commands for modern lists and document libraries. Does not provision ExpiryDate.",
|
"description": "Registers ExpiryIndicator commands for modern lists and document libraries. Does not provision ExpiryDate.",
|
||||||
"id": "913402af-ab9a-4974-9f86-5c2159ae41db",
|
"id": "913402af-ab9a-4974-9f86-5c2159ae41db",
|
||||||
"version": "1.0.3.0",
|
"version": "1.0.4.0",
|
||||||
"assets": {
|
"assets": {
|
||||||
"elementManifests": [
|
"elementManifests": [
|
||||||
"elements.xml"
|
"elements.xml"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "expiry-indicator",
|
"name": "expiry-indicator",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0 <9.0.0"
|
"node": ">=6.9.0 <9.0.0"
|
||||||
|
|||||||
@@ -95,9 +95,7 @@ export class ExpiryConfigService {
|
|||||||
private _createConfigurationList(): Promise<IConfigurationListInfo> {
|
private _createConfigurationList(): Promise<IConfigurationListInfo> {
|
||||||
const body: any = {
|
const body: any = {
|
||||||
'__metadata': { 'type': 'SP.List' },
|
'__metadata': { 'type': 'SP.List' },
|
||||||
'AllowContentTypes': false,
|
|
||||||
'BaseTemplate': 100,
|
'BaseTemplate': 100,
|
||||||
'ContentTypesEnabled': false,
|
|
||||||
'Description': 'Technische Konfiguration der ExpiryIndicator-App.',
|
'Description': 'Technische Konfiguration der ExpiryIndicator-App.',
|
||||||
'Title': CONFIGURATION_LIST_TITLE
|
'Title': CONFIGURATION_LIST_TITLE
|
||||||
};
|
};
|
||||||
@@ -164,7 +162,13 @@ export class ExpiryConfigService {
|
|||||||
this._configurationListUrl(),
|
this._configurationListUrl(),
|
||||||
SPHttpClient.configurations.v1,
|
SPHttpClient.configurations.v1,
|
||||||
options
|
options
|
||||||
).then((): void => undefined);
|
).then((response: SPHttpClientResponse): Promise<void> => {
|
||||||
|
if (!response.ok) {
|
||||||
|
return responseError(response, 'Konfigurationsliste konnte nicht ausgeblendet werden')
|
||||||
|
.then((error: Error): Promise<void> => Promise.reject(error));
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getConfigurationItem(listId: string): Promise<IConfigurationItem | undefined> {
|
private _getConfigurationItem(listId: string): Promise<IConfigurationItem | undefined> {
|
||||||
@@ -202,7 +206,10 @@ export class ExpiryConfigService {
|
|||||||
private _headers(method?: string): any {
|
private _headers(method?: string): any {
|
||||||
const headers: any = {
|
const headers: any = {
|
||||||
'Accept': 'application/json;odata=verbose',
|
'Accept': 'application/json;odata=verbose',
|
||||||
'Content-type': 'application/json;odata=verbose'
|
'Content-type': 'application/json;odata=verbose',
|
||||||
|
// SPFx 1.4.1 defaults to OData 4.0. SharePoint's verbose REST payloads
|
||||||
|
// with __metadata use OData 3.0, especially for write requests on-premises.
|
||||||
|
'OData-Version': '3.0'
|
||||||
};
|
};
|
||||||
if (method) {
|
if (method) {
|
||||||
headers['IF-MATCH'] = '*';
|
headers['IF-MATCH'] = '*';
|
||||||
@@ -211,4 +218,3 @@ export class ExpiryConfigService {
|
|||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ export class ExpiryItemService {
|
|||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json;odata=verbose',
|
'Accept': 'application/json;odata=verbose',
|
||||||
'Content-type': 'application/json;odata=verbose',
|
'Content-type': 'application/json;odata=verbose',
|
||||||
|
'OData-Version': '3.0',
|
||||||
'IF-MATCH': '*',
|
'IF-MATCH': '*',
|
||||||
'X-HTTP-Method': 'MERGE'
|
'X-HTTP-Method': 'MERGE'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,19 +2,29 @@ import { SPHttpClientResponse } from '@microsoft/sp-http';
|
|||||||
|
|
||||||
export function responseError(response: SPHttpClientResponse, operation: string): Promise<Error> {
|
export function responseError(response: SPHttpClientResponse, operation: string): Promise<Error> {
|
||||||
return response.text().then((body: string): Error => {
|
return response.text().then((body: string): Error => {
|
||||||
let detail: string = body;
|
let detail: string = body || response.statusText || 'Unbekannter SharePoint-Fehler';
|
||||||
try {
|
try {
|
||||||
const parsed: any = JSON.parse(body);
|
const parsed: any = JSON.parse(body);
|
||||||
detail = parsed.error && parsed.error.message ? parsed.error.message.value : body;
|
const payload: any = parsed.error || parsed['odata.error'] || (parsed.d && parsed.d.error);
|
||||||
|
const message: any = payload && payload.message;
|
||||||
|
if (typeof message === 'string') {
|
||||||
|
detail = message;
|
||||||
|
} else if (message && typeof message.value === 'string') {
|
||||||
|
detail = message.value;
|
||||||
|
} else if (typeof parsed.Message === 'string') {
|
||||||
|
detail = parsed.Message;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Keep the raw response body.
|
// Keep the raw response body.
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Error(operation + ' (' + response.status + '): ' + detail);
|
const correlationId: string = response.headers.get('SPRequestGuid') ||
|
||||||
|
response.headers.get('request-id') || '';
|
||||||
|
const correlationSuffix: string = correlationId ? ' [Correlation-ID: ' + correlationId + ']' : '';
|
||||||
|
return new Error(operation + ' (' + response.status + '): ' + detail + correlationSuffix);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function escapeODataString(value: string): string {
|
export function escapeODataString(value: string): string {
|
||||||
return value.replace(/'/g, "''");
|
return value.replace(/'/g, "''");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"alias": "ExpiryIndicatorFieldCustomizer",
|
"alias": "ExpiryIndicatorFieldCustomizer",
|
||||||
"componentType": "Extension",
|
"componentType": "Extension",
|
||||||
"extensionType": "FieldCustomizer",
|
"extensionType": "FieldCustomizer",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"manifestVersion": 2,
|
"manifestVersion": 2,
|
||||||
"requiresCustomScript": false
|
"requiresCustomScript": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"alias": "ExpiryIndicatorCommandSet",
|
"alias": "ExpiryIndicatorCommandSet",
|
||||||
"componentType": "Extension",
|
"componentType": "Extension",
|
||||||
"extensionType": "ListViewCommandSet",
|
"extensionType": "ListViewCommandSet",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"manifestVersion": 2,
|
"manifestVersion": 2,
|
||||||
"requiresCustomScript": false,
|
"requiresCustomScript": false,
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
Reference in New Issue
Block a user