|
6 | 6 | :title="$t('task.task-detail-title')"
|
7 | 7 | :with-header="true"
|
8 | 8 | :show-close="true"
|
| 9 | + :destroy-on-close="true" |
9 | 10 | :visible.sync="visible"
|
10 | 11 | :before-close="handleClose"
|
11 | 12 | @closed="handleClosed"
|
|
44 | 45 | </el-tab-pane>
|
45 | 46 | </el-tabs>
|
46 | 47 | <div class="task-detail-actions">
|
47 |
| - <mo-task-item-actions mode="DETAIL" :task="task" /> |
| 48 | + <div class="action-wrapper action-wrapper-left" v-if="optionsChanged"> |
| 49 | + <el-button @click="resetChanged"> |
| 50 | + {{$t('app.reset')}} |
| 51 | + </el-button> |
| 52 | + </div> |
| 53 | + <div class="action-wrapper action-wrapper-center"> |
| 54 | + <mo-task-item-actions mode="DETAIL" :task="task" /> |
| 55 | + </div> |
| 56 | + <div class="action-wrapper action-wrapper-right" v-if="optionsChanged"> |
| 57 | + <el-button type="primary" @click="saveChanged"> |
| 58 | + {{$t('app.save')}} |
| 59 | + </el-button> |
| 60 | + </div> |
48 | 61 | </div>
|
49 | 62 | </el-drawer>
|
50 | 63 | </template>
|
|
59 | 72 | getFileName,
|
60 | 73 | getFileExtension
|
61 | 74 | } from '@shared/utils'
|
62 |
| - import { EMPTY_STRING, TASK_STATUS } from '@shared/constants' |
| 75 | + import { |
| 76 | + EMPTY_STRING, |
| 77 | + NONE_SELECTED_FILES, |
| 78 | + SELECTED_ALL_FILES, |
| 79 | + TASK_STATUS |
| 80 | + } from '@shared/constants' |
63 | 81 | import TaskItemActions from '@/components/Task/TaskItemActions'
|
64 | 82 | import TaskGeneral from './TaskGeneral'
|
65 | 83 | import TaskActivity from './TaskActivity'
|
|
112 | 130 | formLabelWidth: calcFormLabelWidth(locale),
|
113 | 131 | locale,
|
114 | 132 | activeTab: 'general',
|
115 |
| - graphicWidth: 0 |
| 133 | + graphicWidth: 0, |
| 134 | + optionsChanged: false, |
| 135 | + filesSelection: EMPTY_STRING, |
| 136 | + selectionChangedCount: 0 |
116 | 137 | }
|
117 | 138 | },
|
118 | 139 | computed: {
|
|
141 | 162 | selected: item.selected === 'true',
|
142 | 163 | path: item.path,
|
143 | 164 | name,
|
144 |
| - extension, |
145 |
| - length: item.length, |
| 165 | + extension: `.${extension}`, |
| 166 | + length: parseInt(item.length, 10), |
146 | 167 | completedLength: item.completedLength
|
147 | 168 | }
|
148 | 169 | })
|
|
158 | 179 | }
|
159 | 180 | },
|
160 | 181 | mounted () {
|
161 |
| - window.addEventListener('resize', debounce(() => { |
162 |
| - console.log('resize===>', this.activeTab, this.$refs.taskGraphic) |
163 |
| - if (this.activeTab === 'activity' && this.$refs.taskGraphic) { |
164 |
| - this.$refs.taskGraphic.updateGraphicWidth() |
165 |
| - } |
166 |
| - }, 300)) |
| 182 | + window.addEventListener('resize', this.handleAppResize) |
167 | 183 | },
|
168 | 184 | destroyed () {
|
| 185 | + window.removeEventListener('resize', this.handleAppResize) |
169 | 186 | cached.files = []
|
170 |
| - window.removeEventListener('resize') |
171 | 187 | },
|
172 | 188 | methods: {
|
173 | 189 | handleClose (done) {
|
| 190 | + window.removeEventListener('resize', this.handleAppResize) |
174 | 191 | this.$store.dispatch('task/hideTaskDetail')
|
175 | 192 | },
|
176 | 193 | handleClosed (done) {
|
177 | 194 | this.$store.dispatch('task/updateCurrentTaskGid', EMPTY_STRING)
|
178 | 195 | this.$store.dispatch('task/updateCurrentTaskItem', null)
|
| 196 | + this.optionsChanged = false |
| 197 | + this.resetFaskFilesSelection() |
179 | 198 | },
|
180 | 199 | handleTabBeforeLeave (activeName, oldActiveName) {
|
181 | 200 | this.activeTab = activeName
|
182 |
| - if (oldActiveName !== 'peers') { |
183 |
| - return |
| 201 | + this.optionsChanged = false |
| 202 | + switch (oldActiveName) { |
| 203 | + case 'peers': |
| 204 | + this.$store.dispatch('task/toggleEnabledFetchPeers', false) |
| 205 | + break |
| 206 | + case 'files': |
| 207 | + this.resetFaskFilesSelection() |
| 208 | + break |
184 | 209 | }
|
185 |
| - this.$store.dispatch('task/toggleEnabledFetchPeers', false) |
186 | 210 | },
|
187 | 211 | handleTabClick (tab) {
|
188 | 212 | const { name } = tab
|
189 |
| -
|
190 | 213 | switch (name) {
|
191 | 214 | case 'peers':
|
192 | 215 | this.$store.dispatch('task/toggleEnabledFetchPeers', true)
|
|
198 | 221 | break
|
199 | 222 | }
|
200 | 223 | },
|
| 224 | + resetChanged () { |
| 225 | + const { activeTab } = this |
| 226 | + switch (activeTab) { |
| 227 | + case 'files': |
| 228 | + this.resetFaskFilesSelection() |
| 229 | + this.updateFilesListSelection() |
| 230 | + break |
| 231 | + } |
| 232 | + this.optionsChanged = false |
| 233 | + }, |
| 234 | + saveChanged () { |
| 235 | + const { activeTab } = this |
| 236 | + switch (activeTab) { |
| 237 | + case 'files': |
| 238 | + this.saveFaskFilesSelection() |
| 239 | + break |
| 240 | + } |
| 241 | + this.optionsChanged = false |
| 242 | + }, |
| 243 | + handleAppResize () { |
| 244 | + debounce(() => { |
| 245 | + console.log('resize===>', this.activeTab, this.$refs.taskGraphic) |
| 246 | + if (this.activeTab === 'activity' && this.$refs.taskGraphic) { |
| 247 | + this.$refs.taskGraphic.updateGraphicWidth() |
| 248 | + } |
| 249 | + }, 250) |
| 250 | + }, |
201 | 251 | updateFilesListSelection () {
|
202 | 252 | if (!this.$refs.detailFileList) {
|
203 | 253 | return
|
|
207 | 257 | this.$refs.detailFileList.toggleSelection(selectedFileList)
|
208 | 258 | },
|
209 | 259 | handleSelectionChange (val) {
|
210 |
| - console.log('task detail handleSelectionChange==>', val) |
| 260 | + this.filesSelection = val |
| 261 | + this.selectionChangedCount += 1 |
| 262 | + if (this.selectionChangedCount > 1) { |
| 263 | + this.optionsChanged = true |
| 264 | + } |
| 265 | + }, |
| 266 | + resetFaskFilesSelection () { |
| 267 | + this.filesSelection = EMPTY_STRING |
| 268 | + this.selectionChangedCount = 0 |
| 269 | + }, |
| 270 | + saveFaskFilesSelection () { |
| 271 | + const { gid, filesSelection } = this |
| 272 | + if (filesSelection === NONE_SELECTED_FILES) { |
| 273 | + this.$msg.warning(this.$t('task.select-at-least-one')) |
| 274 | + return |
| 275 | + } |
| 276 | +
|
| 277 | + const options = { |
| 278 | + selectFile: filesSelection !== SELECTED_ALL_FILES ? filesSelection : EMPTY_STRING |
| 279 | + } |
| 280 | + this.$store.dispatch('task/changeTaskOption', { gid, options }) |
211 | 281 | }
|
212 | 282 | }
|
213 | 283 | }
|
|
230 | 300 | width: 100%;
|
231 | 301 | text-align: center;
|
232 | 302 | font-size: 0;
|
| 303 | + padding: 0 1.25rem; |
| 304 | + display: flex; |
| 305 | + align-content: space-between; |
| 306 | + justify-content: space-between; |
233 | 307 | .task-item-actions {
|
234 | 308 | display: inline-block;
|
235 | 309 | &> .task-item-action {
|
|
242 | 316 | vertical-align: middle;
|
243 | 317 | }
|
244 | 318 | }
|
| 319 | + .action-wrapper { |
| 320 | + flex: 1; |
| 321 | + } |
| 322 | + .action-wrapper-left { |
| 323 | + text-align: left; |
| 324 | + } |
| 325 | + .action-wrapper-center { |
| 326 | + padding: 1px 0; |
| 327 | + &> .task-item-actions { |
| 328 | + margin: 0 auto; |
| 329 | + } |
| 330 | + } |
| 331 | + .action-wrapper-right { |
| 332 | + text-align: right; |
| 333 | + } |
245 | 334 | }
|
246 | 335 |
|
247 | 336 | .task-detail-tab {
|
|
266 | 355 | bottom: 0;
|
267 | 356 | }
|
268 | 357 | }
|
| 358 | +
|
| 359 | +.tab-panel-actions { |
| 360 | + display: flex; |
| 361 | + justify-content: space-between; |
| 362 | + position: absolute; |
| 363 | + bottom: -28px; |
| 364 | + left: 0; |
| 365 | + width: 100%; |
| 366 | +} |
269 | 367 | </style>
|
0 commit comments