...
|
...
|
@@ -147,7 +147,7 @@ export function drillToEditPostPage() { |
|
|
|
|
|
export function titleEdited(title) {
|
|
|
return (dispatch, getState) => {
|
|
|
let canSubmit = canSubmitPost(getState(), title, null, null);
|
|
|
let canSubmit = canSubmitPost(getState(), title, null, null, null);
|
|
|
dispatch({
|
|
|
type: POSTING_TITLE_EDITED,
|
|
|
payload: {title, canSubmit},
|
...
|
...
|
@@ -157,7 +157,7 @@ export function titleEdited(title) { |
|
|
|
|
|
export function contentEdited(content) {
|
|
|
return (dispatch, getState) => {
|
|
|
let canSubmit = canSubmitPost(getState(), null, content, null);
|
|
|
let canSubmit = canSubmitPost(getState(), null, content, null, null);
|
|
|
dispatch({
|
|
|
type: POSTING_CONTENT_EDITED,
|
|
|
payload: {content, canSubmit},
|
...
|
...
|
@@ -167,7 +167,7 @@ export function contentEdited(content) { |
|
|
|
|
|
export function boardSelected(sectionName, sectionId) {
|
|
|
return (dispatch, getState) => {
|
|
|
let canSubmit = canSubmitPost(getState(), null, null, sectionName);
|
|
|
let canSubmit = canSubmitPost(getState(), null, null, sectionName, null);
|
|
|
dispatch({
|
|
|
type: POSTING_BOARD_SELECTED,
|
|
|
payload: {sectionName, sectionId, canSubmit},
|
...
|
...
|
@@ -176,26 +176,31 @@ export function boardSelected(sectionName, sectionId) { |
|
|
}
|
|
|
|
|
|
export function assetsSelected(assets) {
|
|
|
return {
|
|
|
type: POSTING_ASSETS_SELECTED,
|
|
|
payload: assets,
|
|
|
};
|
|
|
return (dispatch, getState) => {
|
|
|
let canSubmit = canSubmitPost(getState(), null, null, null, assets);
|
|
|
dispatch({
|
|
|
type: POSTING_ASSETS_SELECTED,
|
|
|
payload: {assets, canSubmit},
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function canSubmitPost(state, newTitle = null, newContent = null, newSectionName = null) {
|
|
|
function canSubmitPost(state, newTitle = null, newContent = null, newSectionName = null, nuewAssets = null) {
|
|
|
let {posting} = state;
|
|
|
let {post} = posting;
|
|
|
let {title, content, sectionName} = post;
|
|
|
let {title, content, sectionName, assets} = post;
|
|
|
|
|
|
let canSubmitPost = false;
|
|
|
|
|
|
let titleValue = newTitle !== null ? newTitle : title;
|
|
|
let contentValue = newContent !== null ? newContent : content;
|
|
|
let sectionNameValue = newSectionName !== null ? newSectionName : sectionName;
|
|
|
let assetsValue = nuewAssets !== null ? nuewAssets : assets.toJS();
|
|
|
|
|
|
let hasAssets = assetsValue.length;
|
|
|
let hasTitleOrContent = titleValue.length > 0 || contentValue.length > 0;
|
|
|
let hasSection = sectionNameValue.length > 0;
|
|
|
if (hasTitleOrContent && hasSection) {
|
|
|
if ((hasTitleOrContent || hasAssets) && hasSection) {
|
|
|
canSubmitPost = true;
|
|
|
}
|
|
|
|
...
|
...
|
|