Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added details to Map #2495

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 67 additions & 3 deletions web/client/actions/__tests__/currentMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ var expect = require('expect');
var {
EDIT_MAP, editMap,
UPDATE_CURRENT_MAP, updateCurrentMap,
ERROR_CURRENT_MAP, errorCurrentMap
ERROR_CURRENT_MAP, errorCurrentMap,
REMOVE_THUMBNAIL, removeThumbnail,
UPDATE_CURRENT_MAP_PERMISSIONS, updateCurrentMapPermissions,
UPDATE_CURRENT_MAP_GROUPS, updateCurrentMapGroups,
RESET_CURRENT_MAP, resetCurrentMap,
ADD_CURRENT_MAP_PERMISSION, addCurrentMapPermission
} = require('../currentMap');


Expand All @@ -32,12 +37,28 @@ describe('Test correctness of the maps actions', () => {
});

it('updateCurrentMap', () => {
let files = [];
let thumbnailData = [];
let thumbnail = "myThumnbnailUrl";
var retval = updateCurrentMap(files, thumbnail);
var retval = updateCurrentMap(thumbnailData, thumbnail);
expect(retval).toExist();
expect(retval.type).toBe(UPDATE_CURRENT_MAP);
expect(retval.thumbnail).toBe(thumbnail);
expect(retval.thumbnailData).toBe(thumbnailData);
});
it('updateCurrentMapGroups', () => {
let groups = {
groups: {
group: {
enabled: true,
groupName: 'everyone',
id: 3
}
}
};
var retval = updateCurrentMapGroups(groups);
expect(retval).toExist();
expect(retval.type).toBe(UPDATE_CURRENT_MAP_GROUPS);
expect(retval.groups).toBe(groups);
});

it('errorCurrentMap', () => {
Expand All @@ -47,5 +68,48 @@ describe('Test correctness of the maps actions', () => {
expect(retval.type).toBe(ERROR_CURRENT_MAP);
expect(retval.errors).toBe(errors);
});
it('updateCurrentMapPermissions', () => {
let permissions = {
SecurityRuleList: {
SecurityRule: {
canRead: true,
canWrite: true,
user: {
id: 6,
name: 'admin'
}
}
}
};
const retval = updateCurrentMapPermissions(permissions);
expect(retval).toExist();
expect(retval.type).toBe(UPDATE_CURRENT_MAP_PERMISSIONS);
expect(retval.permissions).toBe(permissions);
});
it('removeThumbnail', () => {
let resourceId = 1;
const retval = removeThumbnail(resourceId);
expect(retval).toExist();
expect(retval.type).toBe(REMOVE_THUMBNAIL);
expect(retval.resourceId).toBe(resourceId);
});
it('resetCurrentMap', () => {
const retval = resetCurrentMap();
expect(retval).toExist();
expect(retval.type).toBe(RESET_CURRENT_MAP);
});
it('addCurrentMapPermission', () => {
const rule = {
canRead: true,
canWrite: true,
user: {
id: 6,
name: 'admin'
}
};
const retval = addCurrentMapPermission(rule);
expect(retval).toExist();
expect(retval.type).toBe(ADD_CURRENT_MAP_PERMISSION);
});

});
153 changes: 143 additions & 10 deletions web/client/actions/__tests__/maps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,38 @@

var expect = require('expect');
const assign = require('object-assign');
var {
// CREATE_THUMBNAIL, createThumbnail,
const {
toggleDetailsSheet, TOGGLE_DETAILS_SHEET,
toggleGroupProperties, TOGGLE_GROUP_PROPERTIES,
toggleUnsavedChanges, TOGGLE_UNSAVED_CHANGES,
deleteMap, DELETE_MAP,
updateDetails, UPDATE_DETAILS,
saveDetails, SAVE_DETAILS,
deleteDetails, DELETE_DETAILS,
setDetailsChanged, SET_DETAILS_CHANGED,
saveResourceDetails, SAVE_RESOURCE_DETAILS,
openOrFetchDetails, OPEN_OR_FETCH_DETAILS,
backDetails, BACK_DETAILS,
undoDetails, UNDO_DETAILS,
doNothing, DO_NOTHING,
setUnsavedChanged, SET_UNSAVED_CHANGES,
openDetailsPanel, OPEN_DETAILS_PANEL,
closeDetailsPanel, CLOSE_DETAILS_PANEL,
MAP_UPDATING, mapUpdating,
PERMISSIONS_UPDATED, permissionsUpdated,
ATTRIBUTE_UPDATED, attributeUpdated,
SAVE_MAP, saveMap,
DISPLAY_METADATA_EDIT, onDisplayMetadataEdit,
RESET_UPDATING, resetUpdating,
THUMBNAIL_ERROR, thumbnailError,
RESET_CURRENT_MAP, resetCurrentMap,
MAPS_SEARCH_TEXT_CHANGED, mapsSearchTextChanged,
MAPS_LIST_LOAD_ERROR, loadError,
MAP_ERROR, mapError, updatePermissions,
MAP_METADATA_UPDATED, mapMetadataUpdated,
METADATA_CHANGED, metadataChanged,
updateAttribute, saveAll
} = require('../maps');
const {RESET_CURRENT_MAP} = require('../currentMap');
let GeoStoreDAO = require('../../api/GeoStoreDAO');
let oldAddBaseUri = GeoStoreDAO.addBaseUrl;

Expand Down Expand Up @@ -80,9 +95,9 @@ describe('Test correctness of the maps actions', () => {
default: done();
}
count++;
});
}, () => {});
});
it('saveAll - with metadataMap, without thumbnail', (done) => {
it('saveAll - without metadataMap, without thumbnail', (done) => {
const resourceId = 1;
// saveAll(map, metadataMap, nameThumbnail, dataThumbnail, categoryThumbnail, resourceIdMap, options)
const retFun = saveAll({}, null, null, null, null, resourceId, {});
Expand All @@ -94,10 +109,33 @@ describe('Test correctness of the maps actions', () => {
case 1: expect(action.type).toBe("NONE"); break;
case 2: expect(action.type).toBe(RESET_UPDATING); break;
case 3: expect(action.type).toBe(DISPLAY_METADATA_EDIT); break;
case 4: expect(action.type).toBe(RESET_CURRENT_MAP); done(); break;
default: done();
}
count++;
});
}, () => {});
});
it('saveAll - without metadataMap, without thumbnail, detailsChanged', (done) => {
const resourceId = 1;
// saveAll(map, metadataMap, nameThumbnail, dataThumbnail, categoryThumbnail, resourceIdMap, options)
const retFun = saveAll({}, null, null, null, null, resourceId, {});
expect(retFun).toExist();
let count = 0;
retFun((action) => {
switch (count) {
case 0: expect(action.type).toBe(MAP_UPDATING); break;
case 1: expect(action.type).toBe("NONE"); break;
case 2: expect(action.type).toBe(SAVE_RESOURCE_DETAILS); break;
case 3: expect(action.type).toBe(RESET_UPDATING); break;
case 4: expect(action.type).toBe(DISPLAY_METADATA_EDIT); break;
case 5: expect(action.type).toBe(RESET_CURRENT_MAP); done(); break;
default: done();
}
count++;
}, () => ({currentMap: {
detailsChanged: true
}}
));
});
it('updatePermissions with securityRules list & without', (done) => {
const securityRules = {
Expand Down Expand Up @@ -206,10 +244,7 @@ describe('Test correctness of the maps actions', () => {
expect(retval.resourceId).toBe(resourceId);
expect(retval.map).toBe(map);
});
it('resetCurrentMap', () => {
const a = resetCurrentMap();
expect(a.type).toBe(RESET_CURRENT_MAP);
});

it('mapsSearchTextChanged', () => {
const a = mapsSearchTextChanged("TEXT");
expect(a.type).toBe(MAPS_SEARCH_TEXT_CHANGED);
Expand Down Expand Up @@ -243,4 +278,102 @@ describe('Test correctness of the maps actions', () => {
expect(a.prop).toBe(prop);
expect(a.value).toBe(value);
});

it('toggleDetailsSheet', () => {
const detailsSheetReadOnly = true;
const a = toggleDetailsSheet(detailsSheetReadOnly);
expect(a.type).toBe(TOGGLE_DETAILS_SHEET);
expect(a.detailsSheetReadOnly).toBeTruthy();

});
it('toggleGroupProperties', () => {
const a = toggleGroupProperties();
expect(a.type).toBe(TOGGLE_GROUP_PROPERTIES);
});
it('toggleUnsavedChanges', () => {
const a = toggleUnsavedChanges();
expect(a.type).toBe(TOGGLE_UNSAVED_CHANGES);
});
it('updateDetails', () => {
const detailsText = "<p>some value</p>";
const originalDetails = "<p>old value</p>";
const doBackup = true;
const a = updateDetails(detailsText, doBackup, originalDetails);
expect(a.doBackup).toBeTruthy();
expect(a.detailsText).toBe(detailsText);
expect(a.originalDetails).toBe(originalDetails);
expect(a.type).toBe(UPDATE_DETAILS);
});
it('deleteMap', () => {
const resourceId = 1;
const someOpt = {
name: "name"
};
const options = {
someOpt
};
const a = deleteMap(resourceId, options);
expect(a.resourceId).toBe(resourceId);
expect(a.type).toBe(DELETE_MAP);
expect(a.options).toBe(options);
});
it('saveDetails', () => {
const detailsText = "<p>some detailsText</p>";
const a = saveDetails(detailsText);
expect(a.type).toBe(SAVE_DETAILS);
expect(a.detailsText).toBe(detailsText);
});
it('deleteDetails', () => {
const a = deleteDetails();
expect(a.type).toBe(DELETE_DETAILS);
});
it('setDetailsChanged', () => {
const detailsChanged = true;
const a = setDetailsChanged(detailsChanged);
expect(a.type).toBe(SET_DETAILS_CHANGED);
expect(a.detailsChanged).toBe(detailsChanged);
});
it('openOrFetchDetails', () => {
const open = true;
const fetch = true;
const readOnly = true;
const a = openOrFetchDetails({open, fetch, readOnly});
expect(a.type).toBe(OPEN_OR_FETCH_DETAILS);
expect(a.open).toBe(open);
expect(a.fetch).toBe(fetch);
expect(a.readOnly).toBe(readOnly);
});
it('backDetails', () => {
const backupDetails = true;
const a = backDetails(backupDetails);
expect(a.type).toBe(BACK_DETAILS);
expect(a.backupDetails).toBe(backupDetails);
});
it('undoDetails', () => {
const a = undoDetails();
expect(a.type).toBe(UNDO_DETAILS);
});
it('setUnsavedChanged', () => {
const value = true;
const a = setUnsavedChanged(value);
expect(a.type).toBe(SET_UNSAVED_CHANGES);
expect(a.value).toBe(value);
});
it('openDetailsPanel', () => {
const a = openDetailsPanel();
expect(a.type).toBe(OPEN_DETAILS_PANEL);
});
it('closeDetailsPanel', () => {
const a = closeDetailsPanel();
expect(a.type).toBe(CLOSE_DETAILS_PANEL);
});
it('doNothing', () => {
const a = doNothing();
expect(a.type).toBe(DO_NOTHING);
});
it('saveResourceDetails', () => {
const a = saveResourceDetails();
expect(a.type).toBe(SAVE_RESOURCE_DETAILS);
});

});
16 changes: 11 additions & 5 deletions web/client/actions/currentMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ const REMOVE_THUMBNAIL = 'REMOVE_THUMBNAIL';
const RESET_CURRENT_MAP = 'RESET_CURRENT_MAP';
const ADD_CURRENT_MAP_PERMISSION = 'ADD_CURRENT_MAP_PERMISSION';

function editMap(map) {
function editMap(map, openModalProperties) {
return {
type: EDIT_MAP,
map
map,
openModalProperties
};
}

// update the thumbnail and the files property of the currentMap
function updateCurrentMap(files, thumbnail) {
// update the thumbnail and the thumbnailData property of the currentMap
function updateCurrentMap(thumbnailData, thumbnail) {
return {
type: UPDATE_CURRENT_MAP,
thumbnail,
files
thumbnailData
};
}

Expand Down Expand Up @@ -60,6 +61,11 @@ function removeThumbnail(resourceId) {
};
}

/**
* reset current map , `RESET_CURRENT_MAP`
* @memberof actions.maps
* @return {action} of type `RESET_CURRENT_MAP`
*/
function resetCurrentMap() {
return {
type: RESET_CURRENT_MAP
Expand Down
Loading