FEATURE Desactivating pannel for other publication thatn dynamiques papers
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1dcbcfa9b8
commit
6f098e4881
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-components', 'wp-data', 'wp-date', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '2926f9bf61acc4d0cf7e');
|
||||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-components', 'wp-data', 'wp-date', 'wp-editor', 'wp-i18n', 'wp-plugins'), 'version' => '3c86a0bf59d03b58250c');
|
||||
|
|
|
|||
|
|
@ -19,13 +19,10 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
|
||||
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__);
|
||||
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
|
||||
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_5__);
|
||||
/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/date */ "@wordpress/date");
|
||||
/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_date__WEBPACK_IMPORTED_MODULE_6__);
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__);
|
||||
|
||||
/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/date */ "@wordpress/date");
|
||||
/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_date__WEBPACK_IMPORTED_MODULE_5__);
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime");
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__);
|
||||
|
||||
|
||||
|
||||
|
|
@ -35,19 +32,26 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
const ModificationDatePanel = () => {
|
||||
const {
|
||||
modificationDate
|
||||
modificationDate,
|
||||
postType
|
||||
} = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
||||
const meta = select("core/editor").getEditedPostAttribute("meta");
|
||||
const postType = select("core/editor").getCurrentPostType();
|
||||
return {
|
||||
modificationDate: meta?.article_modification_date || ""
|
||||
modificationDate: meta?.article_modification_date || "",
|
||||
postType: postType
|
||||
};
|
||||
});
|
||||
const allowedPostTypes = ["article", "revue"]; // adapte avec tes vrais slugs
|
||||
if (!allowedPostTypes.includes(postType)) {
|
||||
return null;
|
||||
}
|
||||
const {
|
||||
editPost
|
||||
} = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useDispatch)("core/editor");
|
||||
const settings = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_6__.getSettings)();
|
||||
const settings = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_5__.getSettings)();
|
||||
const updateModificationDate = newDate => {
|
||||
const formattedDate = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_6__.format)("Y-m-d H:i:s", newDate);
|
||||
const formattedDate = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_5__.format)("Y-m-d H:i:s", newDate);
|
||||
editPost({
|
||||
meta: {
|
||||
article_modification_date: formattedDate
|
||||
|
|
@ -63,22 +67,22 @@ const ModificationDatePanel = () => {
|
|||
};
|
||||
|
||||
// Formater la date pour l'affichage
|
||||
const displayDate = modificationDate ? (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_6__.dateI18n)(settings.formats.datetime, modificationDate) : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)("Non définie", "dynamiques-modification-date");
|
||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_wordpress_editor__WEBPACK_IMPORTED_MODULE_2__.PluginDocumentSettingPanel, {
|
||||
const displayDate = modificationDate ? (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_5__.dateI18n)(settings.formats.datetime, modificationDate) : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)("Non définie", "dynamiques-modification-date");
|
||||
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)(_wordpress_editor__WEBPACK_IMPORTED_MODULE_2__.PluginDocumentSettingPanel, {
|
||||
name: "modification-date-panel",
|
||||
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)("Dernière mise à jour du papier", "dynamiques-modification-date"),
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", {
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
||||
style: {
|
||||
marginBottom: "12px",
|
||||
fontSize: "12px",
|
||||
color: "#757575"
|
||||
},
|
||||
children: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)("Choisissez ici la dernière date de révision de cet article", "dynamiques-modification-date")
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", {
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
||||
style: {
|
||||
marginBottom: "16px"
|
||||
},
|
||||
children: modificationDate ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Dropdown, {
|
||||
children: modificationDate ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Dropdown, {
|
||||
popoverProps: {
|
||||
placement: "bottom-start"
|
||||
},
|
||||
|
|
@ -86,7 +90,7 @@ const ModificationDatePanel = () => {
|
|||
renderToggle: ({
|
||||
isOpen,
|
||||
onToggle
|
||||
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
||||
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
||||
variant: "secondary",
|
||||
onClick: onToggle,
|
||||
"aria-expanded": isOpen,
|
||||
|
|
@ -100,24 +104,24 @@ const ModificationDatePanel = () => {
|
|||
}),
|
||||
renderContent: ({
|
||||
onClose
|
||||
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("div", {
|
||||
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsxs)("div", {
|
||||
style: {
|
||||
padding: "16px"
|
||||
},
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.DateTimePicker, {
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.DateTimePicker, {
|
||||
currentDate: modificationDate,
|
||||
onChange: newDate => {
|
||||
updateModificationDate(newDate);
|
||||
onClose();
|
||||
},
|
||||
is12Hour: settings.formats.time.includes("a")
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", {
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)("div", {
|
||||
style: {
|
||||
marginTop: "16px",
|
||||
display: "flex",
|
||||
gap: "8px"
|
||||
},
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
||||
variant: "secondary",
|
||||
onClick: () => {
|
||||
clearModificationDate();
|
||||
|
|
@ -127,7 +131,7 @@ const ModificationDatePanel = () => {
|
|||
})
|
||||
})]
|
||||
})
|
||||
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
||||
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
||||
variant: "secondary",
|
||||
onClick: () => updateModificationDate(new Date()),
|
||||
style: {
|
||||
|
|
@ -187,16 +191,6 @@ module.exports = window["wp"]["editor"];
|
|||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/element":
|
||||
/*!*********************************!*\
|
||||
!*** external ["wp","element"] ***!
|
||||
\*********************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = window["wp"]["element"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "@wordpress/i18n":
|
||||
/*!******************************!*\
|
||||
!*** external ["wp","i18n"] ***!
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3,126 +3,139 @@ import { Button, DateTimePicker, Dropdown } from "@wordpress/components";
|
|||
import { PluginDocumentSettingPanel } from "@wordpress/editor";
|
||||
import { useSelect, useDispatch } from "@wordpress/data";
|
||||
import { __ } from "@wordpress/i18n";
|
||||
import { useState } from "@wordpress/element";
|
||||
import { dateI18n, format, getSettings } from "@wordpress/date";
|
||||
|
||||
const ModificationDatePanel = () => {
|
||||
const { modificationDate } = useSelect((select) => {
|
||||
const meta = select("core/editor").getEditedPostAttribute("meta");
|
||||
return {
|
||||
modificationDate: meta?.article_modification_date || "",
|
||||
};
|
||||
});
|
||||
const { modificationDate, postType } = useSelect((select) => {
|
||||
const meta = select("core/editor").getEditedPostAttribute("meta");
|
||||
const postType = select("core/editor").getCurrentPostType();
|
||||
|
||||
const { editPost } = useDispatch("core/editor");
|
||||
const settings = getSettings();
|
||||
return {
|
||||
modificationDate: meta?.article_modification_date || "",
|
||||
postType: postType,
|
||||
};
|
||||
});
|
||||
|
||||
const updateModificationDate = (newDate) => {
|
||||
const formattedDate = format("Y-m-d H:i:s", newDate);
|
||||
editPost({
|
||||
meta: {
|
||||
article_modification_date: formattedDate,
|
||||
},
|
||||
});
|
||||
};
|
||||
const allowedPostTypes = ["article", "revue"]; // adapte avec tes vrais slugs
|
||||
if (!allowedPostTypes.includes(postType)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const clearModificationDate = () => {
|
||||
editPost({
|
||||
meta: {
|
||||
article_modification_date: "",
|
||||
},
|
||||
});
|
||||
};
|
||||
const { editPost } = useDispatch("core/editor");
|
||||
const settings = getSettings();
|
||||
|
||||
// Formater la date pour l'affichage
|
||||
const displayDate = modificationDate
|
||||
? dateI18n(settings.formats.datetime, modificationDate)
|
||||
: __("Non définie", "dynamiques-modification-date");
|
||||
const updateModificationDate = (newDate) => {
|
||||
const formattedDate = format("Y-m-d H:i:s", newDate);
|
||||
editPost({
|
||||
meta: {
|
||||
article_modification_date: formattedDate,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<PluginDocumentSettingPanel
|
||||
name='modification-date-panel'
|
||||
title={__("Dernière mise à jour du papier", "dynamiques-modification-date")}>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: "12px",
|
||||
fontSize: "12px",
|
||||
color: "#757575",
|
||||
}}>
|
||||
{__(
|
||||
"Choisissez ici la dernière date de révision de cet article",
|
||||
"dynamiques-modification-date"
|
||||
)}
|
||||
</div>
|
||||
const clearModificationDate = () => {
|
||||
editPost({
|
||||
meta: {
|
||||
article_modification_date: "",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
<div style={{ marginBottom: "16px" }}>
|
||||
{modificationDate ? (
|
||||
<Dropdown
|
||||
popoverProps={{ placement: "bottom-start" }}
|
||||
contentClassName='edit-post-post-schedule__dialog'
|
||||
renderToggle={({ isOpen, onToggle }) => (
|
||||
<Button
|
||||
variant='secondary'
|
||||
onClick={onToggle}
|
||||
aria-expanded={isOpen}
|
||||
style={{
|
||||
textAlign: "left",
|
||||
width: "100%",
|
||||
justifyContent: "flex-start",
|
||||
color: "#1e1e1e",
|
||||
}}>
|
||||
{displayDate}
|
||||
</Button>
|
||||
)}
|
||||
renderContent={({ onClose }) => (
|
||||
<div style={{ padding: "16px" }}>
|
||||
<DateTimePicker
|
||||
currentDate={modificationDate}
|
||||
onChange={(newDate) => {
|
||||
updateModificationDate(newDate);
|
||||
onClose();
|
||||
}}
|
||||
is12Hour={settings.formats.time.includes("a")}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
marginTop: "16px",
|
||||
display: "flex",
|
||||
gap: "8px",
|
||||
}}>
|
||||
<Button
|
||||
variant='secondary'
|
||||
onClick={() => {
|
||||
clearModificationDate();
|
||||
onClose();
|
||||
}}>
|
||||
{__(
|
||||
"Effacer",
|
||||
"dynamiques-modification-date"
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<Button
|
||||
variant='secondary'
|
||||
onClick={() => updateModificationDate(new Date())}
|
||||
style={{
|
||||
textAlign: "left",
|
||||
width: "100%",
|
||||
justifyContent: "flex-start",
|
||||
color: "#757575",
|
||||
}}>
|
||||
{displayDate}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</PluginDocumentSettingPanel>
|
||||
);
|
||||
// Formater la date pour l'affichage
|
||||
const displayDate = modificationDate
|
||||
? dateI18n(settings.formats.datetime, modificationDate)
|
||||
: __("Non définie", "dynamiques-modification-date");
|
||||
|
||||
return (
|
||||
<PluginDocumentSettingPanel
|
||||
name="modification-date-panel"
|
||||
title={__(
|
||||
"Dernière mise à jour du papier",
|
||||
"dynamiques-modification-date",
|
||||
)}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: "12px",
|
||||
fontSize: "12px",
|
||||
color: "#757575",
|
||||
}}
|
||||
>
|
||||
{__(
|
||||
"Choisissez ici la dernière date de révision de cet article",
|
||||
"dynamiques-modification-date",
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: "16px" }}>
|
||||
{modificationDate ? (
|
||||
<Dropdown
|
||||
popoverProps={{ placement: "bottom-start" }}
|
||||
contentClassName="edit-post-post-schedule__dialog"
|
||||
renderToggle={({ isOpen, onToggle }) => (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={onToggle}
|
||||
aria-expanded={isOpen}
|
||||
style={{
|
||||
textAlign: "left",
|
||||
width: "100%",
|
||||
justifyContent: "flex-start",
|
||||
color: "#1e1e1e",
|
||||
}}
|
||||
>
|
||||
{displayDate}
|
||||
</Button>
|
||||
)}
|
||||
renderContent={({ onClose }) => (
|
||||
<div style={{ padding: "16px" }}>
|
||||
<DateTimePicker
|
||||
currentDate={modificationDate}
|
||||
onChange={(newDate) => {
|
||||
updateModificationDate(newDate);
|
||||
onClose();
|
||||
}}
|
||||
is12Hour={settings.formats.time.includes("a")}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
marginTop: "16px",
|
||||
display: "flex",
|
||||
gap: "8px",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
clearModificationDate();
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
{__("Effacer", "dynamiques-modification-date")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => updateModificationDate(new Date())}
|
||||
style={{
|
||||
textAlign: "left",
|
||||
width: "100%",
|
||||
justifyContent: "flex-start",
|
||||
color: "#757575",
|
||||
}}
|
||||
>
|
||||
{displayDate}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</PluginDocumentSettingPanel>
|
||||
);
|
||||
};
|
||||
|
||||
registerPlugin("modification-date-panel", {
|
||||
render: ModificationDatePanel,
|
||||
render: ModificationDatePanel,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user