Refactor date filters to be only methods and replace moment with dayjs
This commit is contained in:
parent
c179d07969
commit
01f4798e7a
|
|
@ -67,8 +67,8 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
new BundleAnalyzerPlugin({
|
new BundleAnalyzerPlugin({
|
||||||
generateStatsFile: true
|
analyzerMode: 'disabled' // do nothing by default, but be able to generate stats with --profile
|
||||||
}),
|
})
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack serve --progress --config build/webpack.dev.conf.js",
|
"dev": "webpack serve --progress --config build/webpack.dev.conf.js",
|
||||||
|
"analyze": "webpack --profile --json --config build/webpack.dev.conf.js > dist/stats.json && webpack-bundle-analyzer dist/stats.json",
|
||||||
"start": ". ../server/.env && npm run dev",
|
"start": ". ../server/.env && npm run dev",
|
||||||
"lint": "eslint --ext .js,.vue src",
|
"lint": "eslint --ext .js,.vue src",
|
||||||
"fix-lint": "eslint --ext .js,.vue --fix src",
|
"fix-lint": "eslint --ext .js,.vue --fix src",
|
||||||
|
|
@ -48,7 +49,7 @@
|
||||||
"copy-webpack-plugin": "^10.1.0",
|
"copy-webpack-plugin": "^10.1.0",
|
||||||
"css-loader": "^0.28.0",
|
"css-loader": "^0.28.0",
|
||||||
"cy2": "^1.2.1",
|
"cy2": "^1.2.1",
|
||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.7",
|
||||||
"debounce": "^1.2.0",
|
"debounce": "^1.2.0",
|
||||||
"eslint": "^4.15.0",
|
"eslint": "^4.15.0",
|
||||||
"eslint-config-standard": "^10.2.1",
|
"eslint-config-standard": "^10.2.1",
|
||||||
|
|
@ -67,7 +68,6 @@
|
||||||
"html-webpack-plugin": "^5.5.0",
|
"html-webpack-plugin": "^5.5.0",
|
||||||
"lodash": "^4.17.10",
|
"lodash": "^4.17.10",
|
||||||
"mini-css-extract-plugin": "^2.4.5",
|
"mini-css-extract-plugin": "^2.4.5",
|
||||||
"moment": "^2.24.0",
|
|
||||||
"node-notifier": "^5.1.2",
|
"node-notifier": "^5.1.2",
|
||||||
"node-sass": "^4.13.1",
|
"node-sass": "^4.13.1",
|
||||||
"optimize-css-assets-webpack-plugin": "^6.0.1",
|
"optimize-css-assets-webpack-plugin": "^6.0.1",
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<h3
|
<h3
|
||||||
class="project-entry__heading"
|
class="project-entry__heading"
|
||||||
data-cy="project-entry-date">{{ created | datetime }}</h3>
|
data-cy="project-entry-date">{{ createdDateTime }}</h3>
|
||||||
<p
|
<p
|
||||||
class="project-entry__paragraph"
|
class="project-entry__paragraph"
|
||||||
data-cy="project-entry-activity">
|
data-cy="project-entry-activity">
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
<document-block :value="{url: documentUrl}"/>
|
<document-block :value="{url: documentUrl}"/>
|
||||||
</p>
|
</p>
|
||||||
<div class="project-entry__date">
|
<div class="project-entry__date">
|
||||||
{{ created | date }}
|
{{ createdDate }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
import DELETE_PROJECT_ENTRY_MUTATION from '@/graphql/gql/mutations/deleteProjectEntry.gql';
|
import DELETE_PROJECT_ENTRY_MUTATION from '@/graphql/gql/mutations/deleteProjectEntry.gql';
|
||||||
import PROJECT_QUERY from '@/graphql/gql/queries/projectQuery.gql';
|
import PROJECT_QUERY from '@/graphql/gql/queries/projectQuery.gql';
|
||||||
|
import {dateFilter, dateTimeFilter} from '@/filters/date-filter';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['description', 'documentUrl', 'created', 'id', 'readOnly'],
|
props: ['description', 'documentUrl', 'created', 'id', 'readOnly'],
|
||||||
|
|
@ -51,6 +52,15 @@
|
||||||
MoreOptionsWidget,
|
MoreOptionsWidget,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
createdDate() {
|
||||||
|
return dateFilter(this.created);
|
||||||
|
},
|
||||||
|
createdDateTime() {
|
||||||
|
return dateTimeFilter(this.created);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
editProjectEntry() {
|
editProjectEntry() {
|
||||||
this.$store.dispatch('editProjectEntry', this.id);
|
this.$store.dispatch('editProjectEntry', this.id);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<span class="comment__owner-name">{{ comment.owner.firstName }} {{ comment.owner.lastName }}</span>
|
<span class="comment__owner-name">{{ comment.owner.firstName }} {{ comment.owner.lastName }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment__date">
|
<div class="comment__date">
|
||||||
{{ comment.created | datetime }}
|
{{ createdDate }}
|
||||||
</div>
|
</div>
|
||||||
<div class="comment__text">
|
<div class="comment__text">
|
||||||
{{ comment.text }}
|
{{ comment.text }}
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import UserWidget from '@/components/UserWidget';
|
import UserWidget from '@/components/UserWidget';
|
||||||
|
import {dateTimeFilter} from '@/filters/date-filter';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -26,6 +27,11 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {UserWidget},
|
components: {UserWidget},
|
||||||
|
computed: {
|
||||||
|
createdDate() {
|
||||||
|
return dateTimeFilter(this.comment.created);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
import moment from 'moment';
|
import dayjs from 'dayjs';
|
||||||
|
require('dayjs/locale/de');
|
||||||
|
|
||||||
moment.locale('de');
|
dayjs.locale('de');
|
||||||
|
|
||||||
|
// todo: test
|
||||||
export const dateFilter = value => {
|
export const dateFilter = value => {
|
||||||
if (value) {
|
if (value) {
|
||||||
return moment(String(value)).format('DD. MMMM YYYY');
|
return dayjs(String(value)).format('DD. MMMM YYYY');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// todo: test
|
||||||
export const dateTimeFilter = value => {
|
export const dateTimeFilter = value => {
|
||||||
if (value) {
|
if (value) {
|
||||||
return moment(String(value)).format('DD. MMMM YYYY, HH:mm');
|
return dayjs(String(value)).format('DD. MMMM YYYY, HH:mm');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import App from './App';
|
||||||
import {postLoginRedirectUrlKey, router} from './router';
|
import {postLoginRedirectUrlKey, router} from './router';
|
||||||
import store from '@/store/index';
|
import store from '@/store/index';
|
||||||
import VueScrollTo from 'vue-scrollto';
|
import VueScrollTo from 'vue-scrollto';
|
||||||
import {dateFilter, dateTimeFilter} from './filters/date-filter';
|
|
||||||
import autoGrow from '@/directives/auto-grow';
|
import autoGrow from '@/directives/auto-grow';
|
||||||
import clickOutside from '@/directives/click-outside';
|
import clickOutside from '@/directives/click-outside';
|
||||||
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
||||||
|
|
@ -59,9 +58,6 @@ const apolloProvider = new VueApollo({
|
||||||
defaultClient: privateApolloClient,
|
defaultClient: privateApolloClient,
|
||||||
});
|
});
|
||||||
|
|
||||||
Vue.filter('date', dateFilter);
|
|
||||||
Vue.filter('datetime', dateTimeFilter);
|
|
||||||
|
|
||||||
/* guards */
|
/* guards */
|
||||||
|
|
||||||
function getCookieValue(cookieName) {
|
function getCookieValue(cookieName) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue