Initial commit

This commit is contained in:
zhongjin
2020-06-15 10:58:47 +08:00
commit 4f1dfe7564
8590 changed files with 1516878 additions and 0 deletions
@@ -0,0 +1,142 @@
<template>
<a class="catalogCard" @click="onClick">
<div class="catalogCard__column">
<div class="catalogCard__cell cell">
<div class="catalogCard__cell--category">
<div class="catalog__icon" :class="`catalog__icon--${formattedCategory}`"></div>
</div>
</div>
<div class="cell cell--main u-flex u-flex__align--center">
<span class="text is-caption is-txtGrey u-ellipsis catalogCard__title">
{{ dataset.name }}
</span>
</div>
</div>
<div class="catalogCard__column">
<div class="cell catalogCard__cell--large u-ellipsis">
<span class="text is-small is-txtSoftGrey">
{{ formattedSpatialAggregations}}
</span>
</div>
</div>
<div class="catalogCard__column">
<div class="cell cell--large u-ellipsis">
<span class="text is-small is-txtSoftGrey">
{{ formattedFrequency }}
</span>
</div>
<div class="cell cell--large u-ellipsis">
<span class="text is-small is-txtSoftGrey">
{{ formattedSource }}
</span>
</div>
</div>
</a>
</template>
<script>
import { mapState } from 'vuex';
export default {
name: 'CatalogCard',
props: {
dataset: Object
},
computed: {
...mapState({
categories: state => state.catalog.categories
}),
formattedSpatialAggregations () {
return this.dataset.spatial_aggregations.join(', ');
},
formattedFrequency () {
return this.dataset.frequency.join(', ');
},
formattedSource () {
return this.dataset.source.join(', ');
},
formattedCategory () {
if (!this.categories.includes(this.dataset.category)) {
return 'default';
}
return this.dataset.category.replace(/ /g, '-').toLowerCase();
}
},
methods: {
onClick (event) {
event.preventDefault();
this.$router.push({
name: 'catalog_detail',
params: {
id: this.dataset.id
},
query: {
category: this.dataset.category,
country: this.dataset.country
}
});
}
}
};
</script>
<style scoped lang="scss">
@import 'new-dashboard/styles/variables';
.catalogCard {
display: flex;
align-items: center;
width: 100%;
padding: 16px;
overflow: hidden;
border-bottom: 1px solid $softblue;
background-color: $white;
cursor: pointer;
&:hover {
background-color: $softblue;
text-decoration: none;
.catalogCard__title {
color: $primary-color;
text-decoration: underline;
}
}
&__column {
display: flex;
flex: 0 0 33.3334%;
justify-content: center;
max-width: 33.3334%;
}
&__cell {
width: 58px;
height: 100%;
padding-left: 0;
&--large {
flex-grow: 1;
flex-shrink: 1;
width: 280px;
}
&--category {
display: flex;
flex-direction: column;
justify-content: center;
width: 36px;
height: 36px;
margin-right: 6px;
padding: 6px;
overflow: hidden;
transition: all 0.25s cubic-bezier(0.4, 0.01, 0.165, 0.99);
border-radius: 2px;
background-color: $thumbnail__bg-color;
}
}
}
</style>
@@ -0,0 +1,345 @@
<template>
<div
v-click-outside="closeDropdown"
class="catalogDropdown"
@keydown.down.prevent="onKeydownDown"
@keydown.up.prevent="onKeydownUp"
:class="{'is-disabled': isDisabled, 'is-open': isOpen}">
<span class="title is-caption catalogDropdown__label">{{ title }}</span>
<div class="catalogDropdown__container">
<div v-if="showInput">
<input type="text"
class="text is-caption catalogDropdown__input"
:class="{ 'has-error': hasError }"
:placeholder="[isOpen ? $t('CatalogDropdown.placeholder') : placeholder]"
v-model="searchFilter"
@focus="onInputFocus"
@click="openDropdown"
@keyup.enter="onKeyEnter"
:disabled="isDisabled || hasError">
</div>
<div v-else
class="text is-caption catalogDropdown__input"
:class="{ 'has-error': hasError }"
@click="openDropdown">
<CatalogDropdownItem :option="searchFilter"/>
<button class="catalogDropdown__close" @click="reset"><img src="../../assets/icons/common/dropdown-close.svg" width="16" height="20" /></button>
</div>
<p class="catalogDropdown__error text is-small" v-if="hasError">{{ error }}</p>
<ul class="catalogDropdown__list"
:class="{'is-open': isOpen, 'is-height-limited': limitHeight}"
@mouseleave="resetActiveOption">
<li
v-for="(option, index) in filteredOptions" :key="option"
@click="selectOption(option)"
class="catalogDropdown__option text is-caption"
:class="{'catalogDropdown__option--active': activeOptionIndex === index + 1}"
@mouseover="updateActiveOption(index + 1)">
<CatalogDropdownItem :option="option"/>
</li>
</ul>
<div class="catalogDropdown__extra">
<slot name="extra"></slot>
</div>
</div>
</div>
</template>
<script>
import CatalogDropdownItem from './CatalogDropdownItem';
export default {
name: 'CatalogDropdown',
components: {
CatalogDropdownItem
},
props: {
title: String,
placeholder: String,
options: {
type: Array,
default () {
return [];
}
},
open: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
limitHeight: {
type: Boolean,
default: false
}
},
data () {
return {
selected: {},
isInputFocused: false,
activeOptionIndex: -1,
searchFilter: '',
isOpen: this.open,
isDisabled: this.disabled,
error: ''
};
},
computed: {
filteredOptions () {
const filtered = [];
const regOption = new RegExp(this.searchFilter, 'ig');
for (const option of this.options) {
if (this.searchFilter.length < 1 || option.match(regOption)) {
filtered.push(option);
}
}
return filtered.length > 0 ? filtered : this.options;
},
hasError () {
return this.error.length > 0;
},
showInput () {
return Object.keys(this.selected).length === 0;
}
},
methods: {
openDropdown () {
this.isOpen = true;
},
closeDropdown () {
this.isOpen = false;
},
disableDropdown () {
this.isDisabled = true;
},
enableDropdown () {
this.isDisabled = false;
},
onInputFocus () {
this.isInputFocused = true;
},
onKeydownDown () {
if (this.activeOptionIndex < this.options.length) {
this.activeOptionIndex++;
}
},
onKeydownUp () {
if (this.activeOptionIndex > 0) {
this.activeOptionIndex--;
}
},
onKeyEnter () {
const optionSelected = this.$el.querySelector('.catalogDropdown__option--active');
if (optionSelected) {
optionSelected.click();
}
},
updateActiveOption (index) {
this.activeOptionIndex = index;
},
resetActiveOption () {
this.activeOptionIndex = -1;
},
selectOption (option) {
this.setInput(option);
this.$emit('selected', this.selected);
},
setInput (option) {
this.enableDropdown();
this.selected = option;
this.searchFilter = this.selected;
this.closeDropdown();
},
clearInput () {
this.searchFilter = '';
this.selected = {};
this.closeDropdown();
},
reset () {
this.clearInput();
this.error = '';
this.$emit('reset');
this.openDropdown();
},
setError (error) {
this.error = error;
}
},
watch: {
disabled () {
this.isDisabled = this.disabled;
},
open () {
this.isOpen = this.open;
}
}
};
</script>
<style scoped lang="scss">
@import 'new-dashboard/styles/variables';
.catalogDropdown {
display: flex;
position: absolute;
z-index: 2;
flex-direction: column;
width: 100%;
&__label {
margin-bottom: 16px;
}
&__container {
position: absolute;
top: 48px;
width: calc(100% - 20px);
}
&__input {
width: 100%;
height: 56px;
padding: 16px 24px;
border: 1px solid $neutral--300;
border-radius: 4px;
&:hover {
cursor: pointer;
.catalogDropdown__close {
display: block;
}
}
&.has-error {
border: 1px solid $warning__border-color;
}
}
&__error {
position: relative;
margin-top: 4px;
padding-left: 24px;
font-size: 12px;
line-height: 16px;
&::before {
content: '';
display: block;
position: absolute;
top: -2px;
left: 0;
width: 18px;
height: 18px;
background-image: url(../../assets/icons/common/warning-icon.svg);
background-repeat: no-repeat;
background-position: center;
background-size: 18px;
}
}
&__close {
display: none;
position: absolute;
top: 18px;
right: 24px;
}
&.is-disabled {
opacity: 0.24;
.catalogDropdown__close {
display: none;
}
}
&.is-open {
.catalogDropdown__input {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
border-top-color: transparent;
border-right-color: transparent;
border-left-color: transparent;
}
.catalogDropdown__list {
border: transparent;
}
.catalogDropdown__container {
border-radius: 4px;
box-shadow: 0 0 0 2px $primary-color;
}
.catalogDropdown__extra {
visibility: visible;
opacity: 1;
pointer-events: auto;
}
}
&:not(.is-open) {
.catalogDropdown__input:hover {
border-color: $text__color;
}
}
}
.catalogDropdown__list {
visibility: hidden;
border: 1px solid $softblue;
opacity: 0;
background-color: $white;
pointer-events: none;
&.is-open {
visibility: visible;
opacity: 1;
pointer-events: auto;
}
&.is-height-limited {
max-height: 196px;
overflow-y: scroll;
}
}
.catalogDropdown__option {
display: block;
position: relative;
width: 100%;
padding: 12px 16px 12px 24px;
overflow: hidden;
color: $primary-color;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
&:not(:last-child) {
border-bottom: 1px solid $softblue;
}
&--active {
background-color: rgba($primary-color, 0.05);
text-decoration: underline;
}
}
.catalogDropdown__extra {
visibility: hidden;
padding: 16px 24px;
border-top: 1px solid $softblue;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
opacity: 0;
background-color: $white;
pointer-events: none;
&--text {
color: $neutral--600;
}
}
</style>
@@ -0,0 +1,30 @@
<template>
<div class="u-flex">
<div :class="`catalog__icon catalog__icon--${getCSSModifier(option)}`"></div>
<span>{{ option }}</span>
</div>
</template>
<script>
import getCSSModifier from 'new-dashboard/utils/get-css-modifier';
export default {
name: 'CatalogDropdownItem',
props: {
option: String
},
methods: {
getCSSModifier
}
};
</script>
<style scoped lang="scss">
.catalog__icon {
width: 24px;
height: 24px;
margin-right: 12px;
background-size: contain;
}
</style>
@@ -0,0 +1,81 @@
<template>
<div class="catalogCardFake">
<div class="catalogCardFake__column u-flex u-flex__align--center">
<div class="catalogCardFake__cell cell-placeholder cell thumbnail">
<div class="icon-placeholder"/>
</div>
<div class="cell-placeholder cell cell--main">
<div class="text-placeholder"/>
</div>
</div>
<div class="catalogCardFake__column">
<div class="cell-placeholder cell cell--xlarge">
<div class="text-placeholder"/>
</div>
</div>
<div class="catalogCardFake__column">
<div class="cell-placeholder cell cell--large">
<div class="text-placeholder"/>
</div>
<div class="cell-placeholder cell cell--large">
<div class="text-placeholder"/>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'CatalogCardFake'
};
</script>
<style scoped lang="scss">
@import 'new-dashboard/styles/variables';
.catalogCardFake {
display: flex;
align-items: center;
width: 100%;
height: 81px;
padding: 22px 14px;
background-color: $white;
&__column {
display: flex;
flex: 0 0 33.3334%;
justify-content: center;
max-width: 33.3334%;
}
&__cell {
width: 58px;
height: 100%;
padding-left: 0;
}
.icon-placeholder {
width: 36px;
height: 36px;
border-radius: 2px;
background-color: $softblue;
}
.text-placeholder {
height: 24px;
background-color: $softblue;
}
.cell-placeholder {
padding: 0 10px;
}
.thumbnail {
padding-right: 16px;
padding-left: 6px;
}
}
</style>
@@ -0,0 +1,132 @@
<template>
<div class="catalogListHeader">
<div class="catalogListHeader__column">
<div class="catalogListHeader__cell cell">
</div>
<div class="cell cell--main">
<span class="text is-small is-txtSoftGrey catalogListHeader__sort"
:class="{
'is-active': isOrderApplied('name'),
'is-reversed': isReverseOrderApplied('name'),
}">
{{ $t('CatalogListHeader.name') }}
</span>
</div>
</div>
<div class="catalogListHeader__column">
<div class="cell catalogCard__cell--large">
<span class="text is-small is-txtSoftGrey catalogListHeader__sort"
:class="{
'is-active': isOrderApplied('spatial_aggregations'),
'is-reversed': isReverseOrderApplied('spatial_aggregations'),
}">
{{ $t('CatalogListHeader.aggregation') }}
</span>
</div>
</div>
<div class="catalogListHeader__column">
<div class="cell cell--large">
<span class="text is-small is-txtSoftGrey catalogListHeader__sort"
:class="{
'is-active': isOrderApplied('frequency'),
'is-reversed': isReverseOrderApplied('frequency'),
}">
{{ $t('CatalogListHeader.frequency') }}
</span>
</div>
<div class="cell cell--large">
<span class="text is-small is-txtSoftGrey catalogListHeader__sort"
:class="{
'is-active': isOrderApplied('source'),
'is-reversed': isReverseOrderApplied('source'),
}">
{{ $t('CatalogListHeader.source') }}
</span>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'CatalogListHeader',
props: {
order: String,
orderDirection: String
},
methods: {
changeOrder (order) {
if (this.order === order) {
return this.setOrder(
order,
this.getOppositeOrderDirection(this.orderDirection)
);
}
this.setOrder(order);
},
getOppositeOrderDirection (order) {
if (order === 'desc') {
return 'asc';
}
if (order === 'asc') {
return 'desc';
}
},
isOrderApplied (order) {
return order === this.order;
},
isReverseOrderApplied (order) {
return order === this.order && this.orderDirection === 'asc';
},
setOrder (order, direction = 'desc') {
this.$emit('changeOrder', { order, direction });
}
}
};
</script>
<style scoped lang="scss">
@import 'new-dashboard/styles/variables';
.catalogListHeader {
display: flex;
align-items: center;
width: 100%;
padding: 16px;
overflow: hidden;
border-bottom: 1px solid $softblue;
background-color: $white;
cursor: default;
&__column {
display: flex;
flex: 0 0 33.3334%;
max-width: 33.3334%;
}
&__cell {
width: 58px;
height: 100%;
padding-left: 0;
&--large {
flex-grow: 1;
flex-shrink: 1;
width: 280px;
}
}
}
.catalogListHeader__sort {
&.is-active,
&:hover {
color: $text__color;
cursor: pointer;
}
}
</style>
@@ -0,0 +1,64 @@
<template>
<div class="catalogRequestSuccess">
<div class="catalogRequestSuccess__icon">
<img svg-inline src="../../assets/icons/catalog/request-success.svg" />
</div>
<p ref="catalogRequestSuccessText" class="catalogRequestSuccess__text text is-small">{{ $t('CatalogDetailPage.requestSuccess')}}</p>
</div>
</template>
<script>
export default {
name: 'CatalogRequestSuccess',
mounted () {
this.$refs.catalogRequestSuccessText.classList.add('animate');
}
};
</script>
<style scoped lang="scss">
@import "new-dashboard/styles/variables";
.catalogRequestSuccess {
display: flex;
align-items: center;
width: 290px;
&__icon {
flex-shrink: 0;
width: 28px;
height: 28px;
margin-top: -4px;
.circle-path {
animation: dash 0.5s linear forwards;
animation-delay: 0s;
stroke-dasharray: 80;
stroke-dashoffset: 80;
}
.check-path {
animation: dash 0.5s linear forwards;
animation-delay: 0s;
stroke-dasharray: 35;
stroke-dashoffset: 35;
}
}
&__text {
margin-left: 24px;
transition: opacity 1s ease 0.5s;
opacity: 0;
&.animate {
opacity: 1;
}
}
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
</style>