Skip to content

Commit 4214f71

Browse files
committed
generalized primary key identification
1 parent 0c7654f commit 4214f71

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/matestack/ui/vue_js/components/form/form.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ const componentDef = {
9999
removeItem: function(){
100100
Vue.set(this.data, "_destroy", true)
101101
this.hideNestedForm = true;
102-
if(this.data["id"] == null){
102+
var primaryKey;
103+
if(this.props["primary_key"] != undefined){
104+
primaryKey = this.props["primary_key"];
105+
}else{
106+
primaryKey = id;
107+
}
108+
if(this.data[primaryKey] == null){
103109
this.$parent.deletedNestedNewInstanceFormsCount[this.props["fields_for"]]++;
104110
}
105111
},

lib/matestack/ui/vue_js/components/form/form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def vue_props
5656
emit: ctx.emit,
5757
delay: ctx.delay,
5858
fields_for: ctx.fields_for,
59-
new_instance_on_demand: ctx.new_instance_on_demand
59+
primary_key: context.for&.class&.primary_key
6060
}
6161
end
6262

0 commit comments

Comments
 (0)