Skip to content

Commit

Permalink
Added the geolocation configuration field type.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjandatta committed Oct 3, 2018
1 parent b7a0e6f commit 8a6bcac
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 26 deletions.
14 changes: 14 additions & 0 deletions build/helper/fieldSchemaXML.js
Expand Up @@ -123,6 +123,16 @@ exports.FieldSchemaXML = function (fieldInfo) {
// Resolve the request
_resolve(schemaXml);
};
// Returns the schema xml for a geolocation field.
var createGeolocation = function (fieldInfo, props) {
var schemaXml = null;
// Set the field type
props["Type"] = "Geolocation";
// Generate the schema
schemaXml = "<Field " + toString(props) + " />";
// Resolve the request
_resolve(schemaXml);
};
// Returns the schema xml for a lookup field.
var createLookup = function (fieldInfo, props) {
var schemaXml = null;
Expand Down Expand Up @@ -371,6 +381,10 @@ exports.FieldSchemaXML = function (fieldInfo) {
case spCfg_1.SPCfgFieldType.Date:
createDate(fieldInfo, props);
break;
// Geolocation
case spCfg_1.SPCfgFieldType.Geolocation:
createGeolocation(fieldInfo, props);
break;
// Lookup
case spCfg_1.SPCfgFieldType.Lookup:
createLookup(fieldInfo, props);
Expand Down
15 changes: 8 additions & 7 deletions build/helper/spCfgTypes.js
Expand Up @@ -9,13 +9,14 @@ exports.SPCfgFieldType = {
Choice: 2,
Currency: 3,
Date: 4,
Lookup: 5,
MMS: 6,
Note: 7,
Number: 8,
Text: 9,
Url: 10,
User: 11
Geolocation: 5,
Lookup: 6,
MMS: 7,
Note: 8,
Number: 9,
Text: 10,
Url: 11,
User: 12
};
/**
* SharePoint Configuration Types
Expand Down
1 change: 1 addition & 0 deletions build/helper/types/spCfgTypes.d.ts
Expand Up @@ -5,6 +5,7 @@ export declare type ISPCfgFieldType = {
Choice: number;
Currency: number;
Date: number;
Geolocation: number;
Lookup: number;
MMS: number;
Note: number;
Expand Down
2 changes: 1 addition & 1 deletion build/rest.js
Expand Up @@ -7,7 +7,7 @@ var Mapper = require("./mapper");
* SharePoint REST Library
*/
exports.$REST = {
__ver: 4.28,
__ver: 4.29,
AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
ContextInfo: Lib.ContextInfo,
DefaultRequestToHostFl: false,
Expand Down
1 change: 1 addition & 0 deletions dist/gd-sprest.d.ts
Expand Up @@ -1995,6 +1995,7 @@ declare module 'gd-sprest/helper/types/spCfgTypes' {
Choice: number;
Currency: number;
Date: number;
Geolocation: number;
Lookup: number;
MMS: number;
Note: number;
Expand Down
6 changes: 3 additions & 3 deletions dist/gd-sprest.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gd-sprest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "gd-sprest",
"version": "4.2.8",
"version": "4.2.9",
"description": "An easy way to develop against the SharePoint REST API.",
"author": "Gunjan Datta <me@dattabase.com> (https://gunjandatta.github.io/sprest)",
"license": "<LICENSE>",
Expand Down
18 changes: 18 additions & 0 deletions src/helper/fieldSchemaXML.ts
Expand Up @@ -133,6 +133,20 @@ export const FieldSchemaXML = (fieldInfo: IFieldInfo): PromiseLike<string> => {
_resolve(schemaXml);
}

// Returns the schema xml for a geolocation field.
let createGeolocation = (fieldInfo: IFieldInfo, props: object) => {
let schemaXml: string = null;

// Set the field type
props["Type"] = "Geolocation";

// Generate the schema
schemaXml = "<Field " + toString(props) + " />";

// Resolve the request
_resolve(schemaXml);
}

// Returns the schema xml for a lookup field.
let createLookup = (fieldInfo: IFieldInfoLookup, props: object) => {
let schemaXml: string = null;
Expand Down Expand Up @@ -368,6 +382,10 @@ export const FieldSchemaXML = (fieldInfo: IFieldInfo): PromiseLike<string> => {
case SPCfgFieldType.Date:
createDate(fieldInfo, props);
break;
// Geolocation
case SPCfgFieldType.Geolocation:
createGeolocation(fieldInfo, props);
break;
// Lookup
case SPCfgFieldType.Lookup:
createLookup(fieldInfo, props);
Expand Down
15 changes: 8 additions & 7 deletions src/helper/spCfgTypes.ts
Expand Up @@ -9,13 +9,14 @@ export const SPCfgFieldType: ISPCfgFieldType = {
Choice: 2,
Currency: 3,
Date: 4,
Lookup: 5,
MMS: 6,
Note: 7,
Number: 8,
Text: 9,
Url: 10,
User: 11
Geolocation: 5,
Lookup: 6,
MMS: 7,
Note: 8,
Number: 9,
Text: 10,
Url: 11,
User: 12
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/helper/types/spCfgTypes.ts
Expand Up @@ -5,6 +5,7 @@ export type ISPCfgFieldType = {
Choice: number;
Currency: number;
Date: number;
Geolocation: number;
Lookup: number;
MMS: number;
Note: number;
Expand Down
2 changes: 1 addition & 1 deletion src/rest.ts
Expand Up @@ -250,7 +250,7 @@ export interface IREST {
* SharePoint REST Library
*/
export const $REST: IREST = {
__ver: 4.28,
__ver: 4.29,
AppContext: (siteUrl: string) => { return Lib.Site.getAppContext(siteUrl); },
ContextInfo: Lib.ContextInfo,
DefaultRequestToHostFl: false,
Expand Down
9 changes: 4 additions & 5 deletions test/test.ts
Expand Up @@ -12,15 +12,14 @@ $REST.Search().postquery({
}
})

Helper.SPConfig({
$REST.Helper.SPConfig({
ListCfg: [{
ContentTypes: [
{ Name: "My Item" },
{ Name: "My Document", ParentName: "Document" }
CustomFields: [
{ name: "Location", title: "Location", type: $REST.Helper.SPCfgFieldType.Geolocation },
],
ListInformation: {
BaseTemplate: 100,
Title: "CT Demo"
Title: "Map"
}
}]
}).install();

0 comments on commit 8a6bcac

Please sign in to comment.