Skip to content

Commit

Permalink
Merge pull request #16618 from mshima/skip_ci-cypress_entities
Browse files Browse the repository at this point in the history
Fix vue many-to-many relationships.
  • Loading branch information
DanielFran authored Oct 9, 2021
2 parents ea4e845 + 2569e9d commit 9bf710e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions generators/entity-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { entityClientI18nFiles } = require('../entity-i18n/files');
const utils = require('../utils');
const BaseBlueprintGenerator = require('../generator-base-blueprint');
const {
SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR, REACT, VUE },
SUPPORTED_CLIENT_FRAMEWORKS: { ANGULAR, REACT },
} = require('../generator-constants');
const { GENERATOR_ENTITY_CLIENT } = require('../generator-list');
const { SQL } = require('../../jdl/jhipster/database-types');
Expand Down Expand Up @@ -72,9 +72,7 @@ module.exports = class extends BaseBlueprintGenerator {

setupCypress() {
const entity = this.entity;
this.cypressBootstrapEntities =
(!entity.reactive || entity.databaseType !== SQL) &&
(this.clientFramework !== VUE || !entity.relationships.some(rel => rel.relationshipRequired && rel.collection));
this.cypressBootstrapEntities = !entity.reactive || entity.databaseType !== SQL;
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ _%>
<%_ } _%>
<%_ for (relationship of relationships) { _%>
<%_ if (relationship.relationshipValidate && relationship.relationshipRequired) { _%>
<%= relationship.relationshipFieldName %>: {
<%= relationship.collection ? relationship.relationshipFieldNamePlural : relationship.relationshipFieldName %>: {
required
},
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ _%>
<%_ } else if (relationship.relationshipManyToMany && ownerSide) { _%>
<div class="form-group">
<label v-text="$t('<%= translationKey %>')" for="<%= entityFileName %>-<%= relationshipName %>"><%= relationshipNameHumanized %></label>
<select class="form-control" id="<%= entityFileName %>-<%= relationshipName %>" data-cy="<%= relationshipFieldName %>" multiple name="<%= relationshipName %>" v-if="<%=entityInstance %>.<%=relationshipFieldNamePlural %> !== undefined" v-model="<%=entityInstance %>.<%=relationshipFieldNamePlural %>"<% if (relationshipRequired) { %> required<% } %>>
<select class="form-control" id="<%= entityFileName %>-<%= relationshipFieldNamePlural %>" data-cy="<%= relationshipFieldName %>" multiple name="<%= relationshipName %>" v-if="<%=entityInstance %>.<%=relationshipFieldNamePlural %> !== undefined" v-model="<%=entityInstance %>.<%=relationshipFieldNamePlural %>"<% if (relationshipRequired) { %> required<% } %>>
<option v-bind:value="getSelected(<%=entityInstance %>.<%=relationshipFieldNamePlural %>, <%=otherEntityName %>Option)" v-for="<%=otherEntityName %>Option in <%=otherEntityNamePlural %>" :key="<%=otherEntityName %>Option.id">{{<%=otherEntityName %>Option.<%=otherEntityField %>}}</option>
</select>
</div>
<%_ } _%>
<%_ if (relationship.relationshipValidate) { _%>
<div v-if="$v.<%= entityInstance %>.<%= relationshipName %>.$anyDirty && $v.<%= entityInstance %>.<%= relationshipName %>.$invalid">
<div v-if="$v.<%= entityInstance %>.<%= relationship.collection ? relationshipFieldNamePlural : relationshipFieldName %>.$anyDirty && $v.<%= entityInstance %>.<%= relationship.collection ? relationshipFieldNamePlural : relationshipFieldName %>.$invalid">
<%_ if (relationshipRequired) { _%>
<small class="form-text text-danger" v-if="!$v.<%= entityInstance %>.<%= relationshipName %>.required" v-text="$t('entity.validation.required')">
<small class="form-text text-danger" v-if="!$v.<%= entityInstance %>.<%= relationship.collection ? relationshipFieldNamePlural : relationshipFieldName %>.required" v-text="$t('entity.validation.required')">
This field is required.
</small>
<%_ } _%>
Expand Down

0 comments on commit 9bf710e

Please sign in to comment.