Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createLayout: function() {
// don't need to cache as it is only re-rendered when there is a change
var configured,
layout,
visible,
i,
view;
configured = lang.getObject('preferences.home.visible', false, App) || [];
layout = [{
id: 'actions',
children: [{
'name': 'AddAccountContactAction',
'action': 'addAccountContact',
'title': this.addAccountContactText
}]
}];
visible = {
id: 'views',
children: []
};
for (i = 0; i < configured.length; i++) {
view = App.getView(configured[i]);
if (lang.exists('data.values.settings.components.map.crowdsourceLayer.fields.PrimaryPhoto.extras',updatedItemInfo)) {
lang.setObject('data.values.settings.components.map.crowdsourceLayer.fields.PrimaryPhoto.extras.minimumSize',1000,updatedItemInfo);
}
// Add source attribute
lang.setObject('data.source','StoryMap_Crowdsource_Builder',updatedItemInfo);
// Update version
lang.setObject('data.values.properties.version',newVersion,updatedItemInfo);
lang.setObject('data.values.properties.versionUpdated',new Date().getTime(),updatedItemInfo);
// Update webmap layers to use https
if (appState.mode.isBuilder) {
const portal = lang.getObject('app.portal',false,appState);
const webmap = lang.getObject('data.values.settings.components.map.webmap',false,currentItemInfo);
const layerId = lang.getObject('data.values.settings.components.map.crowdsourceLayer.id',false,currentItemInfo);
const token = lang.getObject('app.portal.user.credential.token',false,appState);
const itemUrl = portal.portalUrl.stripTrailingSlash() + '/content/items/' + webmap;
const updateWebmapItem = function (item,data) {
let url;
if (data && data.operationalLayers) {
data.operationalLayers = data.operationalLayers.reduce((prev,current) => {
if (current.id === layerId) {
url = new URI(current.url).protocol('https').href();
current.url = url;
}
return prev.concat(current);
},[]);
data.baseMap.baseMapLayers = data.baseMap.baseMapLayers.reduce((prev,current) => {
checkContributeView() {
if (lang.getObject('appState.app.contributing.active',false,this) && lang.getObject('appState.app.contributing.view',false,this) === 'login' && lang.getObject('appState.user.contributor',false,this)) {
AppActions.updateContributeState({
view: 'form'
});
}
}
return prev.concat(ftr);
},[]);
const rejectedFeatures = rejected.reduce((prev,current) => {
const ftr = {
attributes: {}
};
ftr.attributes[idField] = current;
ftr.attributes[vettedField] = 2;
return prev.concat(ftr);
},[]);
const updates = JSON.stringify([].concat(approvedFeatures).concat(rejectedFeatures));
const token = lang.getObject('appState.app.portal.user.credential.token',false,this);
const layer = lang.getObject('appState.app.map.layer',false,this);
const url = layer.url.stripTrailingSlash() + '/applyEdits';
const content = {
f: 'json',
token,
updates
};
esriRequest({
url,
handleAs: 'json',
content
},{
usePost: true
}).then((res) => {
if (res.updateResults) {
checkLoginStatus() {
const portal = lang.getObject('appState.app.portal',false,this);
const pendingLogin = lang.getObject('appState.user.pendingLogin',false,this);
if (!this.checkLoginOnFirstContribute && lang.getObject('appState.app.contributing.active',false,this) && lang.getObject('appState.app.contributing.view',false,this) === 'login') {
this.checkLoginOnFirstContribute = true;
IdentityManager.checkSignInStatus(portal.portalUrl).then(() => {
portal.signIn().then(() => {
this.verifyCredentials();
});
},(err) => {
_onStatus(err.message,true);
});
}
if (pendingLogin && pendingLogin.method) {
if (pendingLogin.method === 'oauth') {
this.pendingLogin = pendingLogin;
this.loginWithOAuth(this.pendingLogin.service);
}
createApp() {
this.savedOrgDefaults = true;
this.savedWebmapDefaults = true;
this.savedAppFromScratchApp = true;
const portal = lang.getObject('appState.app.portal',false,this);
portal.saveApp().then((res) => {
if (res.success) {
_onStatus('App Created: ' + JSON.stringify(res),true);
const url = window.location.origin + window.location.pathname + '?appid=' + res.id;
ItemActions.updateAppItem({
id: res.id,
url
});
this.saveApp(this.registerApp);
}
},(err) => {
AppActions.displayMainError(builderText.errors.scratchCreation.unknown);
_onError(err);
checkOverlayComponentVisibility() {
const featuresInExtent = lang.getObject('appState.app.map.featuresInExtent',false,this);
const selectedFeatureId = lang.getObject('appState.app.map.selectedFeatureId',false,this);
const contributing = lang.getObject('appState.app.contributing.active',false,this);
if (!contributing && selectedFeatureId && featuresInExtent.length > 0 && this.visibleComponents.indexOf(componentNames.SELECTED_SHARES) < 0) {
AppActions.changeComponentsVisibility({show: componentNames.SELECTED_SHARES, hide: componentNames.INTRO});
} else if (!selectedFeatureId && this.visibleComponents.indexOf(componentNames.SELECTED_SHARES) >= 0) {
AppActions.hideComponent(componentNames.SELECTED_SHARES);
}
if (contributing && this.visibleComponents.indexOf(componentNames.CONTRIBUTE) < 0) {
AppActions.changeComponentsVisibility({show: [componentNames.CONTRIBUTE,componentNames.MAP], hide: [componentNames.INTRO, componentNames.SELECTED_SHARES]});
} else if (!contributing && this.visibleComponents.indexOf(componentNames.CONTRIBUTE) >= 0) {
AppActions.hideComponent(componentNames.CONTRIBUTE);
}
}
updateAppState() {
this.appState = AppStore.getState();
if (!this.savedOrgDefaults && lang.getObject('appState.app.portal',false,this)) {
this.saveOrgDefaults();
}
if (!this.savedWebmapDefaults && typeof lang.getObject('appState.items.webmap.item.id',false,this) === 'string' && lang.getObject('appState.items.webmap.item.access',false,this) && !lang.getObject('appState.app.loading.map',false,this) && !lang.getObject('appState.app.loading.data',false,this)) {
this.saveAppFromWebmapDefaults();
}
if (!this.savedAppFromScratchApp && lang.getObject('appState.config.appid',false,this) && typeof lang.getObject('appState.config.appid',false,this) === 'string' && lang.getObject('appState.config.appid',false,this).length === 32 && !lang.getObject('appState.app.loading.map',false,this) && !lang.getObject('appState.app.loading.data',false,this)) {
this.saveAppFromScratchApp();
}
if (lang.getObject('appState.builder.activeDialog',false,this) === 'savingFromScratch' && !this.itemCreationPending) {
this.createFeatureService();
}
if (this.showCoverPageSettingsOnLoad && lang.getObject('appState.app.loading.data',false,this) && lang.getObject('appState.app.loading.map',false,this)) {
this.showCoverPageSettingsOnLoad = false;
setTimeout(() => {
AppActions.showComponent([componentNames.SIDE_PANEL_SETTINGS,componentNames.SIDE_PANEL_SETTINGS_STRING_MATCH + componentNames.SPS_INTRO_SPLASH]);
},1000);
}
}
checkAppShareChange() {
const startingShare = lang.getObject('appState.items.app.item.access',false,this);
const currentShare = lang.getObject('appState.builder.appShare',false,this);
const sharePending = lang.getObject('appState.builder.appSharePending',false,this);
if (this.currentShare === undefined && startingShare) {
this.currentShare = startingShare;
BuilderActions.updateShare(this.currentShare);
} else if (this.currentShare !== currentShare && !sharePending) {
this.prevShare = this.currentShare;
this.currentShare = currentShare;
BuilderActions.updateSharingStatus(true);
const portal = lang.getObject('appState.app.portal',false,this);
portal.shareItems({
org: this.currentShare !== 'private' ? true : false,