mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
save: public switch completed
This commit is contained in:
parent
b7f2c7c382
commit
4d126461ea
5 changed files with 18 additions and 12 deletions
|
@ -15,8 +15,7 @@ module.exports = async (req, res) => {
|
|||
const logo = parseString(body.logo, 16);
|
||||
const provider = parseString(body.provider, 16) || 'DEFAULT';
|
||||
const distance = parseNumber(body.distance, 0, 1000);
|
||||
|
||||
console.log('SAVING PROVIDER?', provider, body.provider);
|
||||
const is_public = !!body.is_public;
|
||||
|
||||
if ((!route || route.length <= 0) && (!stickers || stickers.length <= 0)) {
|
||||
return res.send({ success: false, mode: 'empty' });
|
||||
|
@ -29,23 +28,23 @@ module.exports = async (req, res) => {
|
|||
|
||||
if (exists) {
|
||||
exists.set({
|
||||
title, route, stickers, logo, distance, updated_at: Date.now(), provider,
|
||||
title, route, stickers, logo, distance, updated_at: Date.now(), provider, is_public,
|
||||
}).save();
|
||||
|
||||
return res.send({
|
||||
success: true, title, address, route, stickers, mode: 'overwrited'
|
||||
success: true, title, address, route, stickers, mode: 'overwrited', is_public,
|
||||
});
|
||||
}
|
||||
|
||||
const created = await Route.create({
|
||||
_id: address, title, route, stickers, owner, logo, distance, provider,
|
||||
_id: address, title, route, stickers, owner, logo, distance, provider, is_public,
|
||||
});
|
||||
|
||||
await owner.routes.push(created);
|
||||
await owner.save();
|
||||
|
||||
return res.send({
|
||||
success: true, title, address, route, stickers, provider,
|
||||
success: true, title, address, route, stickers, provider, is_public,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ export class SaveDialog extends React.Component<Props, State> {
|
|||
<div className="button" onClick={this.onCopy}>Скопировать</div>
|
||||
}
|
||||
{ save_finished &&
|
||||
<div className="button success" onClick={this.cancelSaving}>Отлично, спасибо!</div>
|
||||
<div className="button success" onClick={this.cancelSaving}>Отлично!</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
setSaveError,
|
||||
setSaveOverwrite, setSaveSuccess, setTitle,
|
||||
searchSetTab,
|
||||
setUser, setDialog,
|
||||
setUser, setDialog, setPublic,
|
||||
} from '$redux/user/actions';
|
||||
import { getUrlData, parseQuery, pushLoaderState, pushNetworkInitError, pushPath, replacePath } from '$utils/history';
|
||||
import { editor } from '$modules/Editor';
|
||||
|
@ -277,7 +277,7 @@ function* sendSaveRequestSaga({ title, address, force, is_public }) {
|
|||
if (result && result.mode === 'exists') return yield put(setSaveError(TIPS.SAVE_EXISTS));
|
||||
if (timeout || !result || !result.success || !result.address) return yield put(setSaveError(TIPS.SAVE_TIMED_OUT));
|
||||
|
||||
return yield put(setSaveSuccess({ address: result.address, save_error: TIPS.SAVE_SUCCESS, title }));
|
||||
return yield put(setSaveSuccess({ address: result.address, save_error: TIPS.SAVE_SUCCESS, title, is_public: result.is_public }));
|
||||
}
|
||||
|
||||
// function* refreshUserData() {
|
||||
|
@ -478,7 +478,7 @@ function* searchSetTabSaga() {
|
|||
yield call(searchSetSaga);
|
||||
}
|
||||
|
||||
function* setSaveSuccessSaga({ address, title }) {
|
||||
function* setSaveSuccessSaga({ address, title, is_public }) {
|
||||
const { id } = yield select(getUser);
|
||||
const { dialog_active } = yield select(getState);
|
||||
|
||||
|
@ -486,6 +486,7 @@ function* setSaveSuccessSaga({ address, title }) {
|
|||
|
||||
yield put(setTitle(title));
|
||||
yield put(setAddress(address));
|
||||
yield put(setPublic(is_public));
|
||||
yield put(setChanged(false));
|
||||
|
||||
yield editor.owner = { id };
|
||||
|
|
|
@ -359,6 +359,11 @@
|
|||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z" fill="white" stroke="none" stroke-width="0" transform="translate(4 4)"/>
|
||||
</g>
|
||||
|
||||
<g id="icon-edit-1" stroke="none">
|
||||
<path stroke="none" fill="black"/>
|
||||
<path d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" fill="white" stroke="none" stroke-width="0" transform="translate(4 4)"/>
|
||||
</g>
|
||||
|
||||
<g id="icon-sad-1" stroke="none">
|
||||
<path stroke="none" fill="black"/>
|
||||
<g transform="translate(4 4)">
|
||||
|
@ -370,5 +375,5 @@
|
|||
</svg>
|
||||
</defs>
|
||||
|
||||
<use xlink:href="#icon-sad-1" />
|
||||
<use xlink:href="#icon-edit-1" />
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
@ -20,7 +20,7 @@ export const getStoredMap = ({ name }) => axios.get(API.GET_MAP, {
|
|||
}).then(result => (result && result.data && result.data.success && result.data));
|
||||
|
||||
export const postMap = ({
|
||||
title, address, route, stickers, id, token, force, logo, distance, provider,
|
||||
title, address, route, stickers, id, token, force, logo, distance, provider, is_public,
|
||||
}) => axios.post(API.POST_MAP, {
|
||||
title,
|
||||
address,
|
||||
|
@ -32,6 +32,7 @@ export const postMap = ({
|
|||
logo,
|
||||
distance,
|
||||
provider,
|
||||
is_public,
|
||||
}).then(result => (result && result.data && result.data));
|
||||
|
||||
export const checkIframeToken = ({ viewer_id, auth_key }) => axios.get(API.IFRAME_LOGIN_VK, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue