Skip to content

Commit 33ef81a

Browse files
bronsolobronsolo
authored andcommitted
fix addprop for cols
check duplicate column names add new cols to object once appended
1 parent 4b3ac14 commit 33ef81a

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

plotly/plotlygrid.m

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@
169169
end
170170

171171
%-check for duplicate column names-%
172+
for c = 1:length(cols)
173+
if ~isempty(intersect(cols{c}.name,fieldnames(obj)))
174+
errkey = 'gridCols:duplicateName';
175+
error(errkey, gridmsg(errkey))
176+
end
177+
end
172178

173179
%-endpoint-%
174180
endpoint = obj.Endpoints.Col;
@@ -184,6 +190,13 @@
184190
errkey = 'gridGeneric:genericError';
185191
error(errkey,[gridmsg(errkey) response.detail]);
186192
end
193+
194+
%-append new columns-%
195+
for c = 1:length(cols)
196+
obj.File.cols{end + 1} = response.cols{c};
197+
obj.Data.(cols{c}.name) = cols{c}.data;
198+
obj.addColProps;
199+
end
187200
end
188201
end
189202

@@ -195,21 +208,27 @@
195208
fields = fieldnames(obj.Data);
196209

197210
for d = 1:length(fields)
198-
199-
% add property field
200-
addprop(obj,fields{d});
201-
202-
% create column object
203-
plotlycol = plotlycolumn(obj.Data.(fields{d}), ...
204-
obj.File.cols{d}.name, obj.File.cols{d}.uid, obj.File.fid);
205-
206-
% initialize property field
207-
obj.(fields{d}) = plotlycol;
211+
if ~isprop(obj, fields{d})
212+
213+
% add property field
214+
addprop(obj,fields{d});
215+
216+
% create column object
217+
plotlycol = plotlycolumn(obj.Data.(fields{d}), ...
218+
obj.File.cols{d}.name, obj.File.cols{d}.uid, obj.File.fid);
219+
220+
% initialize property field
221+
obj.(fields{d}) = plotlycol;
222+
223+
end
208224
end
209225

210226
end
211227

212-
function varargout = makecall(obj, request, endpoint, payload)
228+
function response = makecall(obj, request, endpoint, payload)
229+
230+
%-initialize ouptut-%
231+
response = '';
213232

214233
%-encoding-%
215234
encoder = sun.misc.BASE64Encoder();
@@ -229,7 +248,7 @@
229248
response_handler(resp);
230249

231250
%-structure resp-%
232-
varargout{1} = loadjson(resp);
251+
response = loadjson(resp);
233252
end
234253
end
235254
end

0 commit comments

Comments
 (0)