Correct toolbar title

This commit is contained in:
SergeyEzhin 2021-12-15 19:02:22 +04:00
parent 46099dc36f
commit dc77d400cc
3 changed files with 6 additions and 18 deletions

View file

@ -7,7 +7,6 @@ import ToolbarView from "../view/Toolbar";
const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'storeFocusObjects', 'storeToolbarSettings','storeDocumentInfo')(observer(props => { const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'storeFocusObjects', 'storeToolbarSettings','storeDocumentInfo')(observer(props => {
const {t} = useTranslation(); const {t} = useTranslation();
const _t = t("Toolbar", { returnObjects: true }); const _t = t("Toolbar", { returnObjects: true });
const appOptions = props.storeAppOptions; const appOptions = props.storeAppOptions;
const isDisconnected = props.users.isDisconnected; const isDisconnected = props.users.isDisconnected;
const displayMode = props.storeReview.displayMode; const displayMode = props.storeReview.displayMode;
@ -23,8 +22,10 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'sto
const showEditDocument = !appOptions.isEdit && appOptions.canEdit && appOptions.canRequestEditRights; const showEditDocument = !appOptions.isEdit && appOptions.canEdit && appOptions.canRequestEditRights;
const docInfo = props.storeDocumentInfo;
const docTitle = docInfo.dataDoc ? docInfo.dataDoc.title : '';
useEffect(() => { useEffect(() => {
Common.Notifications.on('setdoctitle', setDocTitle);
Common.Gateway.on('init', loadConfig); Common.Gateway.on('init', loadConfig);
Common.Notifications.on('toolbar:activatecontrols', activateControls); Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
@ -37,19 +38,12 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview', 'sto
} }
return () => { return () => {
// Common.Notifications.off('setdoctitle', setDocTitle);
Common.Notifications.off('toolbar:activatecontrols', activateControls); Common.Notifications.off('toolbar:activatecontrols', activateControls);
Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.off('goback', goBack); Common.Notifications.off('goback', goBack);
} }
}); });
const docInfo = props.storeDocumentInfo;
const [docTitle, resetDocTitle] = useState(docInfo.dataDoc ? docInfo.dataDoc.title : '');
const setDocTitle = (title) => {
resetDocTitle(title);
}
// Back button // Back button
const [isShowBack, setShowBack] = useState(appOptions.canBackToFolder); const [isShowBack, setShowBack] = useState(appOptions.canBackToFolder);
const loadConfig = (data) => { const loadConfig = (data) => {

View file

@ -21,8 +21,10 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeFocusObjects'
const isCanRedo = storeToolbarSettings.isCanRedo; const isCanRedo = storeToolbarSettings.isCanRedo;
const disabledPreview = storeToolbarSettings.countPages <= 0; const disabledPreview = storeToolbarSettings.countPages <= 0;
const docInfo = props.storePresentationInfo;
const docTitle = docInfo.dataDoc ? docInfo.dataDoc.title : '';
useEffect(() => { useEffect(() => {
Common.Notifications.on('setdoctitle', setDocTitle);
Common.Gateway.on('init', loadConfig); Common.Gateway.on('init', loadConfig);
Common.Notifications.on('toolbar:activatecontrols', activateControls); Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
@ -35,19 +37,12 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeFocusObjects'
} }
return () => { return () => {
Common.Notifications.off('setdoctitle', setDocTitle);
Common.Notifications.off('toolbar:activatecontrols', activateControls); Common.Notifications.off('toolbar:activatecontrols', activateControls);
Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.off('goback', goBack); Common.Notifications.off('goback', goBack);
} }
}); });
const docInfo = props.storePresentationInfo;
const [docTitle, resetDocTitle] = useState(docInfo.dataDoc ? docInfo.dataDoc.title : '');
const setDocTitle = (title) => {
resetDocTitle(title);
}
// Back button // Back button
const [isShowBack, setShowBack] = useState(appOptions.canBackToFolder); const [isShowBack, setShowBack] = useState(appOptions.canBackToFolder);
const loadConfig = (data) => { const loadConfig = (data) => {

View file

@ -27,7 +27,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
useEffect(() => { useEffect(() => {
Common.Gateway.on('init', loadConfig); Common.Gateway.on('init', loadConfig);
Common.Notifications.on('toolbar:activatecontrols', activateControls); Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
Common.Notifications.on('goback', goBack); Common.Notifications.on('goback', goBack);