|
67 | 67 | </b-col> |
68 | 68 | <b-col cols="9"> |
69 | 69 | <v-select v-if="projects" :options="projects" v-model="resource.gids" |
70 | | - :reduce="r=>r.group_id" label="name" multiple/> |
| 70 | + :reduce="r=>r.group_id" label="name" multiple> |
| 71 | + <template v-slot:option="project"> |
| 72 | + <span :class="{ |
| 73 | + 'resource-projects-all__vs__dropdown-option': project.group_id == 1, |
| 74 | + 'resource-projects-private__vs__dropdown-option': project.private, |
| 75 | + }"> |
| 76 | + {{ project.name }} |
| 77 | + <span class="resource-projects-all_admin-message" v-if="config.hasRole('admin') && project.group_id == 1"> |
| 78 | + (Brainlife Administrators Only) |
| 79 | + </span> |
| 80 | + </span> |
| 81 | + </template> |
| 82 | + <template v-slot:selected-option="project"> |
| 83 | + <span :class="{ |
| 84 | + 'resource-projects-all__vs__selected': project.group_id == 1, |
| 85 | + 'resource-projects-private__vs__selected': project.private, |
| 86 | + }"> |
| 87 | + {{ project.name }} |
| 88 | + </span> |
| 89 | + </template> |
| 90 | + </v-select> |
71 | 91 | <p> |
72 | 92 | <small>Please select projects that you'd like enable this resource. Any jobs submitted by any member of specified project will be executed on this resource. You have to be listed as administrator of the project to be able to select it.</small> |
73 | 93 | </p> |
@@ -314,23 +334,37 @@ export default { |
314 | 334 | }}).then(res=>{ |
315 | 335 | this.projects = res.data.projects; |
316 | 336 |
|
317 | | - //brainlife admin can add global user (but only site admin can *add* it) |
318 | | - //if(this.config.hasRole('admin')) { |
319 | | - this.projects.push({ |
320 | | - group_id: 1, |
321 | | - name: "(Public Resource)", |
322 | | - desc: "Share this resource with all brainlife users - only brainlife administrator can add this" |
| 337 | + this.projects.forEach(p => { |
| 338 | + p.private = false; |
323 | 339 | }); |
324 | 340 |
|
| 341 | + if ( |
| 342 | + // brainlife admin can add global user (but only site admin can *add* it) |
| 343 | + this.config.hasRole('admin') || |
| 344 | +
|
| 345 | + // if you are editing a resource and it has already public permission |
| 346 | + (this.resource._id && this.resource.gids.includes(1)) |
| 347 | + ) { |
| 348 | + this.projects.push({ |
| 349 | + group_id: 1, |
| 350 | + name: "All Projects", |
| 351 | + desc: "Share this resource with all Brainlife users - only Brainlife administrators can add this", |
| 352 | + private: false, |
| 353 | + }); |
| 354 | + } |
| 355 | +
|
325 | 356 | //add private groups that user doesn't have access to.. so the value won't disappear |
326 | | - this.resource.gids.forEach(gid=>{ |
327 | | - const project = this.projects.find(p=>p.group_id == gid); |
328 | | - if(!project) this.projects.push({ |
| 357 | + this.resource.gids.forEach(gid => { |
| 358 | + const project = this.projects.find(p => p.group_id == gid); |
| 359 | + if (!project) { |
| 360 | + this.projects.push({ |
329 | 361 | group_id: gid, |
330 | | - name: "(Private Project "+gid+")", |
| 362 | + name: "Private Project", |
331 | 363 | desc: "You don't have access to this project by it was added by other administrator", |
332 | | - }); |
333 | | - }); |
| 364 | + private: true, |
| 365 | + }); |
| 366 | + } |
| 367 | + }); |
334 | 368 | }); |
335 | 369 | }, |
336 | 370 |
|
@@ -443,5 +477,22 @@ export default { |
443 | 477 | small { |
444 | 478 | opacity: 0.5; |
445 | 479 | } |
| 480 | +.resource-projects-all_admin-message { |
| 481 | + color: #C00; |
| 482 | +} |
| 483 | +.resource-projects-all__vs__selected { |
| 484 | + color: #393; |
| 485 | + font-weight: bold; |
| 486 | +} |
| 487 | +.resource-projects-private__vs__selected { |
| 488 | + color: #999; |
| 489 | +} |
| 490 | +.resource-projects-all__vs__dropdown-option { |
| 491 | + color: #393; |
| 492 | + font-weight: bold; |
| 493 | +} |
| 494 | +.resource-projects-private__vs__dropdown-option { |
| 495 | + color: #999; |
| 496 | +} |
446 | 497 | </style> |
447 | 498 |
|
0 commit comments