Skip to content

Instantly share code, notes, and snippets.

@cici004
Created April 21, 2016 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cici004/c23362cf9d1e5c52f20efaaa1fb0282e to your computer and use it in GitHub Desktop.
Save cici004/c23362cf9d1e5c52f20efaaa1fb0282e to your computer and use it in GitHub Desktop.
Config-Search
/*eslint no-alert: 0*/
define([
'dojo/on',
'dojo/_base/lang',
'dojo/date/locale'
], function (on, lang, locale) {
'use strict';
function formatDateTime (value) {
if (value instanceof Date) {
return locale.format(value, {
formatLength: 'short'
});
}
return '';
}
function formatDate (value) {
if (value instanceof Date) {
return locale.format(value, {
selector: 'date',
formatLength: 'medium'
});
}
return '';
}
function getDateTime (value) {
if (isNaN(value) || value === 0 || value === null) {
return null;
}
return new Date(value);
}
return {
map: true,
mapClickMode: true,
layers: [
{
name: 'Search by Postmile',
expression: '', // additional where expression applied to all queries
idProperty: 'objectid_1',
queryParameters: {
type: 'spatial', // spatial, relationship, table or database
url: 'http://sv04esri:6080/arcgis/rest/services/Survey/ControlPoints/MapServer/0',
// layerID: 'DamageAssessment', // from operational layers
// sublayerID: 0,
outFields: ['*']
},
attributeSearches: [
{
name: 'Search by Postmile',
searchFields: [
{
name: 'County',
label: 'County',
expression: '(county LIKE \'[value]%\')',
placeholder: 'Select a County',
values: ['Alameda','Contra','Marin','Napa','San Francisco','San Mateo','Santa Clara','Solano','Sonoma'],
required: true,
minChars: 3
},
{
name: 'Route',
label: 'Route',
expression: '(route LIKE \'[value]%\')',
placeholder: 'Select a Route',
values: ['13', '24', '61', '77', '80', '84', '92', '112', '123', '185','205', '238', '260', '262', '580', '680', '880', '980'],
required: true,
// minChars: 2
},
{
name: 'Postmile From',
label: 'Postmile From',
expression: '(pm>[value])',
placeholder: 'From',
required: true
},
{
name: 'Postmile To',
label: 'Postmile To',
expression: '(pm<[value])',
placeholder: 'To',
required: true
}
],
title: 'Search by PM',
topicID: 'SearchbyPM',
sort: [
{
attribute: 'incidentnm',
descending: 'ASC'
}
]
}
]
},
{
name: 'Search by EA/SR',
expression: '', // additional where expression applied to all queries
idProperty: 'objectid_1',
queryParameters: {
type: 'spatial', // spatial, relationship, table or database
url: 'http://sv04esri:6080/arcgis/rest/services/Survey/ControlPoints/MapServer/0',
// layerID: 'DamageAssessment', // from operational layers
// sublayerID: 0,
outFields: ['*']
},
attributeSearches: [
{
name: 'Search by EA/SR',
searchFields: [
{
name: 'Enter SR Attribute',
label: 'Enter SR Attribute',
expression: '(surv_req LIKE\'[value]%\')',
placeholder: 'ex SR: 08-213',
required:false,
minChars: 3
},
{
name: 'Enter EA Attribute',
label: 'Or Enter EA Attribute',
expression: '(dist_ea LIKE \'[value]%\')',
placeholder: 'ex EA: 2A7901',
//values: ['Destroyed', 'Major', 'Minor'],
require: false,
minChars: 3
}
],
title: 'Control Points',
topicID: 'Control Points',
sort: [
{
attribute: 'NAME',
descending: 'ASC'
}
]
// }
}
]
}
]
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment