Skip to content

Commit 202a027

Browse files
committedJan 16, 2018
refactor(browser): when a team is available, it is not selected by default
1 parent a50162b commit 202a027

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed
 

‎views/api/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const mock = {
161161
create: config => createAPI('/mock/create', 'post', config),
162162
update: config => createAPI('/mock/update', 'post', config),
163163
delete: config => createAPI('/mock/delete', 'post', config),
164-
export: config => createExportForm('/mock/export', config)
164+
export: config => createExportForm('/api/mock/export', config)
165165
}
166166

167167
const group = {

‎views/locale/en.js

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export default {
106106
create: 'Create Success',
107107
update: 'Update Success',
108108
delete: '{name} is deleted'
109+
},
110+
error: {
111+
groupIsNull: 'Please select the project belongs to'
109112
}
110113
},
111114
formatError: 'File only supports JSON/YML format',

‎views/locale/zh-CN.js

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export default {
106106
create: '创建成功',
107107
update: '更新成功',
108108
delete: '{name} 已删除'
109+
},
110+
error: {
111+
groupIsNull: '请选择项目归属'
109112
}
110113
},
111114
formatError: '文件仅支持 JSON/YML 格式',

‎views/pages/new/project.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ export default {
170170
this.form.groupId = proj.user._id
171171
}
172172
} else {
173-
this.fetchGroup()
174-
this.form.groupId = this.user.id
173+
this.fetchGroup().then(groups => {
174+
if (groups.length < 2) {
175+
this.form.groupId = this.user.id
176+
}
177+
})
175178
}
176179
},
177180
computed: {
@@ -218,7 +221,7 @@ export default {
218221
: newUrl.replace(/\/\//g, '/').replace(/\/$/, '')
219222
},
220223
fetchGroup () {
221-
api.group.getList().then((res) => {
224+
return api.group.getList().then((res) => {
222225
if (res.data.success) {
223226
this.groups = [{ value: this.user.id, label: this.user.nickName }].concat(
224227
res.data.data.map(o => ({
@@ -227,6 +230,7 @@ export default {
227230
}))
228231
)
229232
}
233+
return this.groups
230234
})
231235
},
232236
submit () {
@@ -249,6 +253,14 @@ export default {
249253
}
250254
})
251255
} else {
256+
if (this.form.groupId === '') {
257+
this.$Message.error({
258+
content: this.$t('p.new.form.error.groupIsNull'),
259+
duration: 5
260+
})
261+
return
262+
}
263+
252264
if (data.group === this.user.id) {
253265
data.group = ''
254266
}

0 commit comments

Comments
 (0)