forked from projects/fipamo
updated post data model for editited date, edited api to save editiable date
This commit is contained in:
parent
5229db1668
commit
47f76e65fc
7 changed files with 132 additions and 15 deletions
|
@ -43,6 +43,11 @@ module.exports = function (sequelize, DataTypes) {
|
|||
type: DataTypes.INTEGER,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
origin_date: {
|
||||
type: DataTypes.INTEGER,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
timestamps: true,
|
||||
|
|
|
@ -124,12 +124,12 @@ router.get('/entries/edit/:id', function (req, res) {
|
|||
|
||||
//let newdate = new Date(entry.created_at);
|
||||
//let formattedDate = newdate.getFullYear()+"-"+newdate.getMonth()+"-"+newdate.getDate();
|
||||
let sexydate = DateUtils.getDate('stamp', entry.created_at)
|
||||
let sexydate = DateUtils.getDate('stamp', entry.origin_date)
|
||||
res.render('dash/entry-edit', {
|
||||
title: 'Edit Entry',
|
||||
mode: 'admin',
|
||||
post: entry,
|
||||
date:sexydate,
|
||||
date:entry.origin_date,
|
||||
colored: pretty,
|
||||
html: entry.entry_plaintext,
|
||||
feature: featured,
|
||||
|
|
107
themes/dash/assets/js/dash.min.js
vendored
107
themes/dash/assets/js/dash.min.js
vendored
|
@ -702,6 +702,7 @@ function () {
|
|||
postData.append("title", document.getElementById('entry_title').value);
|
||||
postData.append('slug', new _StringUtils.default().cleanString(document.getElementById('entry_title').value));
|
||||
postData.append("entry_plaintext", txt.value);
|
||||
postData.append("created_date", document.getElementById('option-date').value);
|
||||
postData.append("tags", document.getElementById('entry_tags').value);
|
||||
var postURL;
|
||||
var postEventType;
|
||||
|
@ -748,7 +749,94 @@ function () {
|
|||
}();
|
||||
|
||||
exports.default = EntryTasks;
|
||||
},{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/utilities/StringUtils":"tools/utilities/StringUtils.jsx"}],"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js":[function(require,module,exports) {
|
||||
},{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/utilities/StringUtils":"tools/utilities/StringUtils.jsx"}],"tools/utilities/DateUtils.jsx":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
var DateUtils =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
function DateUtils() {
|
||||
_classCallCheck(this, DateUtils);
|
||||
} //--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
|
||||
|
||||
_createClass(DateUtils, [{
|
||||
key: "getMKtime",
|
||||
value: function getMKtime() {
|
||||
var time = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), new Date().getSeconds(), 0).getTime() / 1000;
|
||||
return time;
|
||||
}
|
||||
}, {
|
||||
key: "convertMKtime",
|
||||
value: function convertMKtime(seconds) {
|
||||
var date = new Date(seconds * 1000);
|
||||
return date;
|
||||
}
|
||||
}, {
|
||||
key: "getDate",
|
||||
value: function getDate(type, rawdate) {
|
||||
var day = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate());
|
||||
var month = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1);
|
||||
var year = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear());
|
||||
var hour = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours());
|
||||
var minute = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes());
|
||||
var seconds = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds());
|
||||
var millisecond = rawdate != null || rawdate != '' ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds());
|
||||
var offset = rawdate != null || rawdate != '' ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset());
|
||||
if (day.length == 1) day = String("0" + day);
|
||||
if (month.length == 1) month = String("0" + month);
|
||||
offset = String(offset / 60);
|
||||
if (offset.length == 1) offset = String("0" + offset);
|
||||
|
||||
switch (type) {
|
||||
case "day":
|
||||
return day;
|
||||
break;
|
||||
|
||||
case "month":
|
||||
return month;
|
||||
break;
|
||||
|
||||
case "year":
|
||||
return year;
|
||||
break;
|
||||
|
||||
case "stamp":
|
||||
return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds + "." + millisecond + "-" + offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
return String(year + "-" + month + "-" + day);
|
||||
break;
|
||||
}
|
||||
} //--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
|
||||
}]);
|
||||
|
||||
return DateUtils;
|
||||
}();
|
||||
|
||||
var _default = DateUtils;
|
||||
exports.default = _default;
|
||||
},{}],"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js":[function(require,module,exports) {
|
||||
var define;
|
||||
var global = arguments[3];
|
||||
(function (global, factory) {
|
||||
|
@ -2453,6 +2541,8 @@ var _DataUtils = _interopRequireWildcard(require("./DataUtils"));
|
|||
|
||||
var DataEvent = _interopRequireWildcard(require("../events/DataEvent"));
|
||||
|
||||
var _DateUtils = _interopRequireDefault(require("./DateUtils"));
|
||||
|
||||
var _tinyDatePicker = _interopRequireDefault(require("tiny-date-picker"));
|
||||
|
||||
var _caretPos = require("caret-pos");
|
||||
|
@ -2479,10 +2569,17 @@ function () {
|
|||
this.setInputs();
|
||||
hljs.initHighlightingOnLoad();
|
||||
this.dataUtils = new _DataUtils.default();
|
||||
this.dateUtils = new _DateUtils.default();
|
||||
this.url = '';
|
||||
(0, _tinyDatePicker.default)(document.getElementById('option-date', {
|
||||
mode: 'dp-modal'
|
||||
}));
|
||||
var self = this;
|
||||
this.dp = (0, _tinyDatePicker.default)('input');
|
||||
(0, _tinyDatePicker.default)(document.getElementById('option-date'), {
|
||||
mode: 'dp-below',
|
||||
format: function format(date) {
|
||||
//return date;
|
||||
return self.dateUtils.getDate('origin', date);
|
||||
}
|
||||
});
|
||||
window.addEventListener("scroll", function (f) {
|
||||
var fixLimit = document.getElementById('header').offsetHeight + document.getElementById('entry-header').offsetHeight + document.getElementById('entry-feature').offsetHeight;
|
||||
|
||||
|
@ -2635,7 +2732,7 @@ function () {
|
|||
|
||||
var _default = TextEditor;
|
||||
exports.default = _default;
|
||||
},{"./DataUtils":"tools/utilities/DataUtils.jsx","../events/DataEvent":"tools/events/DataEvent.jsx","tiny-date-picker":"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","caret-pos":"../../../../node_modules/caret-pos/lib/esm2015/main.js"}],"controllers/DashEntry.jsx":[function(require,module,exports) {
|
||||
},{"./DataUtils":"tools/utilities/DataUtils.jsx","../events/DataEvent":"tools/events/DataEvent.jsx","./DateUtils":"tools/utilities/DateUtils.jsx","tiny-date-picker":"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","caret-pos":"../../../../node_modules/caret-pos/lib/esm2015/main.js"}],"controllers/DashEntry.jsx":[function(require,module,exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -39,6 +39,7 @@ class EntryTasks {
|
|||
postData.append("title", document.getElementById('entry_title').value);
|
||||
postData.append('slug', new StringUtils().cleanString(document.getElementById('entry_title').value));
|
||||
postData.append("entry_plaintext", txt.value);
|
||||
postData.append("created_date", document.getElementById('option-date').value);
|
||||
postData.append("tags", document.getElementById('entry_tags').value);
|
||||
let postURL;
|
||||
let postEventType;
|
||||
|
|
|
@ -20,16 +20,20 @@ class DateUtils {
|
|||
|
||||
getDate(type, rawdate) {
|
||||
var day = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCDate()) : String(new Date().getUTCDate()));
|
||||
var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth()+1) : String(new Date().getUTCMonth()+1));
|
||||
var month = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMonth() + 1) : String(new Date().getUTCMonth() + 1));
|
||||
var year = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCFullYear()) : String(new Date().getUTCFullYear()));
|
||||
var hour = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCHours()) : String(new Date().getUTCHours()));
|
||||
var minute = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMinutes()) : String(new Date().getUTCMinutes()));
|
||||
var seconds = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCSeconds()) : String(new Date().getUTCSeconds()));
|
||||
var millisecond = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getUTCMilliseconds()) : String(new Date().getUTCMilliseconds()));
|
||||
var offset = ((rawdate != null || rawdate != '') ? String(new Date(rawdate).getTimezoneOffset()) : String(new Date().getTimezoneOffset()));
|
||||
if (day.length == 1)
|
||||
day = String("0" + day);
|
||||
if (month.length == 1)
|
||||
month = String("0" + month);
|
||||
offset = String(offset / 60);
|
||||
if (offset.length == 1)
|
||||
offset = String("0" + offset);
|
||||
switch (type) {
|
||||
case "day":
|
||||
return day;
|
||||
|
@ -41,10 +45,10 @@ class DateUtils {
|
|||
return year;
|
||||
break;
|
||||
case "stamp":
|
||||
return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds+"."+millisecond);
|
||||
return String(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds + "." + millisecond + "-" + (offset));
|
||||
break
|
||||
default:
|
||||
return String(year + "-" + month + "-" + day + " : " + hour + "-" + minute + "-" + seconds);
|
||||
return String(year + "-" + month + "-" + day);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,10 @@ import DataUtils, {
|
|||
CONTENT_TYPE_FORM
|
||||
} from './DataUtils';
|
||||
import * as DataEvent from '../events/DataEvent';
|
||||
import DateUtils from './DateUtils';
|
||||
import TinyDatePicker from 'tiny-date-picker';
|
||||
import {
|
||||
|
||||
position,
|
||||
offset
|
||||
} from 'caret-pos';
|
||||
|
@ -22,10 +24,18 @@ class TextEditor {
|
|||
this.setInputs();
|
||||
hljs.initHighlightingOnLoad();
|
||||
this.dataUtils = new DataUtils();
|
||||
this.dateUtils = new DateUtils();
|
||||
this.url = '';
|
||||
TinyDatePicker(document.getElementById('option-date', {
|
||||
mode: 'dp-modal'
|
||||
}));
|
||||
let self = this;
|
||||
|
||||
this.dp = TinyDatePicker('input');
|
||||
TinyDatePicker(document.getElementById('option-date'), {
|
||||
mode: 'dp-below',
|
||||
format(date) {
|
||||
//return date;
|
||||
return self.dateUtils.getDate('origin', date);
|
||||
}
|
||||
});
|
||||
window.addEventListener("scroll", f => {
|
||||
var fixLimit = document.getElementById('header').offsetHeight + document.getElementById('entry-header').offsetHeight + document.getElementById('entry-feature').offsetHeight
|
||||
if (window.pageYOffset >= fixLimit) {
|
||||
|
|
Loading…
Reference in a new issue