Skip to content

Commit

Permalink
Merge GT-2095-Tool-Groups into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
stage-branch-merger[bot] authored Dec 1, 2023
2 parents 2e5e902 + b47a8a1 commit b754a45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { UUID } from 'angular2-uuid';
import { ToolGroupService } from '../../service/tool-group/tool-group.service';
import { ResourceService } from '../../service/resource/resource.service';
import { Resource } from '../../models/resource';
Expand Down Expand Up @@ -51,12 +52,17 @@ export class ToolGroupResourceComponent implements OnInit {

async createOrUpdate(): Promise<void> {
this.saving = true;
this.errorMessage = [];
const dataErrors = [];
const promises = [];
if (this.tools.length) {
this.tools.forEach((tool) => {
const isUpdate = !!this.initialTools.find(
(item) => item.id === tool.id,
);
if (!tool.suggestionsWeight || tool.suggestionsWeight === '0') {
dataErrors.push(`${tool.tool.name} needs to have a Suggestions Weight larger than 0.`)
}
promises.push(
this.toolGroupService.addOrUpdateTool(
this.toolGroup.id,
Expand All @@ -69,6 +75,12 @@ export class ToolGroupResourceComponent implements OnInit {
});
}

if (dataErrors.length) {
this.saving = false;
this.errorMessage = dataErrors;
return;
}

const results: PromisePayload[] = await Promise.all(
promises.map((p) =>
p
Expand Down Expand Up @@ -125,7 +137,7 @@ export class ToolGroupResourceComponent implements OnInit {
}

generateId(): string {
return Math.floor(Math.random() * 1000).toString();
return UUID.UUID();
}

cancel() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/service/tool-group/tool-group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class ToolGroupService extends AbstractService {
data: {
type: 'tool-group-tool',
attributes: {
'suggestions-weight': suggestionsWeight,
'suggestions-weight': suggestionsWeight || '1.0',
},
relationships: {
tool: {
Expand Down

0 comments on commit b754a45

Please sign in to comment.