Skip to content

Commit e391143

Browse files
authored
Merge pull request #401 from kaizumaki/feature/issue-398-crypto-zip-csv-download
患者詳細画面に患者データcsvをパスワード付きzipでダウンロードする機能を追加
2 parents fcb36ba + 473e7e9 commit e391143

File tree

12 files changed

+273
-275
lines changed

12 files changed

+273
-275
lines changed

components/InputField.vue

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<input
66
:class="['inputField', { 'inputField-error': showError }]"
77
:style="{ fontSize: fontSizeMap.get(fontSize) }"
8-
:type="type"
8+
:type="definedType"
99
:pattern="type === 'number' ? '\\d*' : null"
1010
:name="name"
1111
:placeholder="placeholder"
@@ -15,13 +15,22 @@
1515
:disabled="disabled"
1616
@input="$emit('input', $event.target.value)"
1717
/>
18+
<div v-if="type === 'password'" class="showIcon">
19+
<EyeIcon
20+
v-if="definedType === 'password'"
21+
@click="handleShowPassword(true)"
22+
/>
23+
<EyeOffIcon v-else @click="handleShowPassword(false)" />
24+
</div>
1825
</label>
1926
<span class="message">{{ errorMessage }}</span>
2027
</div>
2128
</template>
2229

2330
<script lang="ts">
2431
import Vue from 'vue'
32+
import EyeIcon from '@/static/icon-eye.svg'
33+
import EyeOffIcon from '@/static/icon-eye-off.svg'
2534
2635
type Rules = {
2736
[key: string]: {
@@ -33,6 +42,10 @@ type SizeType = 'M' | 'S'
3342
type FontSizeType = string
3443
3544
export default Vue.extend({
45+
components: {
46+
EyeIcon,
47+
EyeOffIcon,
48+
},
3649
props: {
3750
label: {
3851
type: String,
@@ -78,13 +91,19 @@ export default Vue.extend({
7891
type: String,
7992
default: '',
8093
},
94+
ruleLength: {
95+
type: Number,
96+
default: 0,
97+
},
8198
},
8299
data(): {
83100
showError: boolean
101+
showPassword: boolean
84102
fontSizeMap: Map<SizeType, FontSizeType>
85103
} {
86104
return {
87105
showError: false,
106+
showPassword: false,
88107
fontSizeMap: new Map([
89108
['M', '20px'],
90109
['S', '16px'],
@@ -98,6 +117,10 @@ export default Vue.extend({
98117
isValid: this.ruleRequired,
99118
message: '必須項目です', // TODO: メッセージを確定させる
100119
},
120+
length: {
121+
isValid: this.value.length >= this.ruleLength,
122+
message: `${this.ruleLength}文字以上必要です`, // TODO: メッセージを確定させる
123+
},
101124
}
102125
},
103126
ruleRequired(): boolean {
@@ -117,6 +140,17 @@ export default Vue.extend({
117140
(key: string) => !this.rules[key].isValid,
118141
)
119142
},
143+
definedType(): string {
144+
if (this.type === 'password') {
145+
if (this.showPassword) {
146+
return 'text'
147+
} else {
148+
return 'password'
149+
}
150+
} else {
151+
return this.type
152+
}
153+
},
120154
},
121155
watch: {
122156
rules() {
@@ -126,11 +160,17 @@ export default Vue.extend({
126160
this.$emit('validate', !this.hasErrors)
127161
},
128162
},
163+
methods: {
164+
handleShowPassword(bool: boolean): void {
165+
this.showPassword = bool
166+
},
167+
},
129168
})
130169
</script>
131170

132171
<style lang="scss" scoped>
133172
.inputFieldContainer {
173+
position: relative;
134174
padding: 12px 0;
135175
}
136176
.inputField {
@@ -162,4 +202,12 @@ export default Vue.extend({
162202
font-size: 14px;
163203
height: 14px;
164204
}
205+
.showIcon {
206+
position: absolute;
207+
bottom: 4px;
208+
right: 8px;
209+
svg {
210+
fill: $gray-3;
211+
}
212+
}
165213
</style>

nuxt.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default {
4646
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
4747
plugins: [
4848
{
49-
src: '@/plugins/vue-apexchart.ts',
49+
src: '@/plugins/vue-apexchart',
5050
ssr: false,
5151
},
5252
{
@@ -102,6 +102,15 @@ export default {
102102
},
103103
},
104104
},
105+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
106+
extend(config, { isDev, isClient }) {
107+
if (isClient) {
108+
config.module.rules.push({
109+
test: /worker\.js$/,
110+
use: [{ loader: 'url-loader' }],
111+
})
112+
}
113+
},
105114
},
106115

107116
publicRuntimeConfig: {

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
"*.{css,vue}": "yarn stylelint"
1919
},
2020
"dependencies": {
21+
"@zip.js/zip.js": "^2.3.8",
2122
"apexcharts": "3.28.1",
2223
"classlist-polyfill": "1.2.0",
2324
"core-js": "3.16.4",
2425
"dayjs": "1.10.6",
26+
"file-saver": "^2.0.5",
2527
"nuxt": "2.15.8",
2628
"nuxt-property-decorator": "2.9.1",
2729
"nuxt-svg-loader": "1.2.0",
30+
"papaparse": "^5.3.1",
2831
"promise-polyfill": "8.2.0",
2932
"vue": "2.6.14",
3033
"vue-apexcharts": "1.6.2",
@@ -42,6 +45,8 @@
4245
"@nuxtjs/eslint-module": "3.0.2",
4346
"@nuxtjs/style-resources": "1.2.1",
4447
"@nuxtjs/stylelint-module": "4.0.0",
48+
"@types/file-saver": "^2.0.3",
49+
"@types/papaparse": "^5.2.6",
4550
"babel-eslint": "10.1.0",
4651
"eslint": "7.32.0",
4752
"eslint-config-prettier": "8.3.0",
@@ -58,6 +63,6 @@
5863
"stylelint-config-standard": "22.0.0",
5964
"ts-loader": "8.3.0",
6065
"typescript": "4.3.5",
61-
"webpack": "5.51.1"
66+
"url-loader": "^4.1.1"
6267
}
6368
}

0 commit comments

Comments
 (0)