311 lines
12 KiB
JavaScript
311 lines
12 KiB
JavaScript
/******/ (() => { // webpackBootstrap
|
|
/******/ "use strict";
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ "./src/modification-date.js":
|
|
/*!**********************************!*\
|
|
!*** ./src/modification-date.js ***!
|
|
\**********************************/
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins");
|
|
/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
|
|
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__);
|
|
/* harmony import */ var _wordpress_editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/editor */ "@wordpress/editor");
|
|
/* harmony import */ var _wordpress_editor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_editor__WEBPACK_IMPORTED_MODULE_2__);
|
|
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
|
|
/* 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__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ModificationDatePanel = () => {
|
|
const {
|
|
modificationDate
|
|
} = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
|
const meta = select("core/editor").getEditedPostAttribute("meta");
|
|
return {
|
|
modificationDate: meta?.article_modification_date || ""
|
|
};
|
|
});
|
|
const {
|
|
editPost
|
|
} = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useDispatch)("core/editor");
|
|
const settings = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_6__.getSettings)();
|
|
const updateModificationDate = newDate => {
|
|
const formattedDate = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_6__.format)("Y-m-d H:i:s", newDate);
|
|
editPost({
|
|
meta: {
|
|
article_modification_date: formattedDate
|
|
}
|
|
});
|
|
};
|
|
const clearModificationDate = () => {
|
|
editPost({
|
|
meta: {
|
|
article_modification_date: ""
|
|
}
|
|
});
|
|
};
|
|
|
|
// 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, {
|
|
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", {
|
|
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", {
|
|
style: {
|
|
marginBottom: "16px"
|
|
},
|
|
children: modificationDate ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Dropdown, {
|
|
popoverProps: {
|
|
placement: "bottom-start"
|
|
},
|
|
contentClassName: "edit-post-post-schedule__dialog",
|
|
renderToggle: ({
|
|
isOpen,
|
|
onToggle
|
|
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
|
variant: "secondary",
|
|
onClick: onToggle,
|
|
"aria-expanded": isOpen,
|
|
style: {
|
|
textAlign: "left",
|
|
width: "100%",
|
|
justifyContent: "flex-start",
|
|
color: "#1e1e1e"
|
|
},
|
|
children: displayDate
|
|
}),
|
|
renderContent: ({
|
|
onClose
|
|
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)("div", {
|
|
style: {
|
|
padding: "16px"
|
|
},
|
|
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.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", {
|
|
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, {
|
|
variant: "secondary",
|
|
onClick: () => {
|
|
clearModificationDate();
|
|
onClose();
|
|
},
|
|
children: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)("Effacer", "dynamiques-modification-date")
|
|
})
|
|
})]
|
|
})
|
|
}) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
|
|
variant: "secondary",
|
|
onClick: () => updateModificationDate(new Date()),
|
|
style: {
|
|
textAlign: "left",
|
|
width: "100%",
|
|
justifyContent: "flex-start",
|
|
color: "#757575"
|
|
},
|
|
children: displayDate
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
(0,_wordpress_plugins__WEBPACK_IMPORTED_MODULE_0__.registerPlugin)("modification-date-panel", {
|
|
render: ModificationDatePanel
|
|
});
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/components":
|
|
/*!************************************!*\
|
|
!*** external ["wp","components"] ***!
|
|
\************************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["components"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/data":
|
|
/*!******************************!*\
|
|
!*** external ["wp","data"] ***!
|
|
\******************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["data"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/date":
|
|
/*!******************************!*\
|
|
!*** external ["wp","date"] ***!
|
|
\******************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["date"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/editor":
|
|
/*!********************************!*\
|
|
!*** external ["wp","editor"] ***!
|
|
\********************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["editor"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/element":
|
|
/*!*********************************!*\
|
|
!*** external ["wp","element"] ***!
|
|
\*********************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["element"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/i18n":
|
|
/*!******************************!*\
|
|
!*** external ["wp","i18n"] ***!
|
|
\******************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["i18n"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "@wordpress/plugins":
|
|
/*!*********************************!*\
|
|
!*** external ["wp","plugins"] ***!
|
|
\*********************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["wp"]["plugins"];
|
|
|
|
/***/ }),
|
|
|
|
/***/ "react/jsx-runtime":
|
|
/*!**********************************!*\
|
|
!*** external "ReactJSXRuntime" ***!
|
|
\**********************************/
|
|
/***/ ((module) => {
|
|
|
|
module.exports = window["ReactJSXRuntime"];
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
/******/ if (cachedModule !== undefined) {
|
|
/******/ return cachedModule.exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/compat get default export */
|
|
/******/ (() => {
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = (module) => {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ () => (module['default']) :
|
|
/******/ () => (module);
|
|
/******/ __webpack_require__.d(getter, { a: getter });
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/define property getters */
|
|
/******/ (() => {
|
|
/******/ // define getter functions for harmony exports
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
/******/ for(var key in definition) {
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
/******/ }
|
|
/******/ }
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
/******/ (() => {
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
/******/ })();
|
|
/******/
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
/******/ (() => {
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = (exports) => {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/ })();
|
|
/******/
|
|
/************************************************************************/
|
|
var __webpack_exports__ = {};
|
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
(() => {
|
|
/*!**********************!*\
|
|
!*** ./src/index.js ***!
|
|
\**********************/
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _modification_date__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modification-date */ "./src/modification-date.js");
|
|
|
|
})();
|
|
|
|
/******/ })()
|
|
;
|
|
//# sourceMappingURL=index.js.map
|