2017-09-05 04:38:38 +02:00
|
|
|
import ACTION_TYPES from './AnchorSelectorActionTypes';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Begin querying a page for anchors
|
|
|
|
*
|
|
|
|
* @param {Number} pageId - ID of page to query for
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function beginUpdating(pageId) {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.ANCHORSELECTOR_UPDATING,
|
|
|
|
payload: { pageId },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finish updating a anchors for a page
|
2019-08-15 09:18:34 +02:00
|
|
|
* By default forces list of anchors for a page ID to be loaded from the server each time the page
|
|
|
|
* is selected to select on if it's anchors from.
|
2017-09-05 04:38:38 +02:00
|
|
|
*
|
|
|
|
* @param {Number} pageId - ID of page to query for
|
|
|
|
* @param {Array} anchors - List of anchor strings
|
2019-08-15 09:18:34 +02:00
|
|
|
* @param {Boolean} cacheResult - false: Refresh anchor list, true: cache result
|
2017-09-05 04:38:38 +02:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2019-08-15 09:18:34 +02:00
|
|
|
export function updated(pageId, anchors, cacheResult = false) {
|
2017-09-05 04:38:38 +02:00
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.ANCHORSELECTOR_UPDATED,
|
2019-08-15 09:18:34 +02:00
|
|
|
payload: { pageId, anchors, cacheResult },
|
2017-09-05 04:38:38 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-06-09 03:23:01 +02:00
|
|
|
/**
|
|
|
|
* Get the anchors that belong in a specific field.
|
|
|
|
* The server doesn't know about anchors that haven't been saved yet, so this allows
|
|
|
|
* a WYSIWYG field to register its own anchors.
|
|
|
|
*
|
|
|
|
* @param {Number} pageId - ID of page to query for
|
|
|
|
* @param {Array} anchors - List of anchor strings
|
|
|
|
* @param {String} fieldID - ID of the field these anchors belong to
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function updatedCurrentField(pageId, anchors, fieldID) {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.ANCHORSELECTOR_CURRENT_FIELD,
|
|
|
|
payload: { pageId, anchors, fieldID },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-09-05 04:38:38 +02:00
|
|
|
/**
|
|
|
|
* Mark a tree as failed
|
|
|
|
*
|
|
|
|
* @param {Number} pageId - ID of page that update failed
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function updateFailed(pageId) {
|
|
|
|
return {
|
|
|
|
type: ACTION_TYPES.ANCHORSELECTOR_UPDATE_FAILED,
|
|
|
|
payload: { pageId },
|
|
|
|
};
|
|
|
|
}
|