MCPcopy Create free account
hub / github.com/facebook/Rapid / noteSaveButtons

Function noteSaveButtons

modules/ui/note_editor.js:269–337  ·  view source on GitHub ↗
(selection)

Source from the content-addressed store, hash-verified

267
268
269 function noteSaveButtons(selection) {
270 var osm = context.services.osm;
271 var hasAuth = osm && osm.authenticated();
272
273 var isSelected = (_note && _note.id === context.selectedIDs()[0]);
274 var buttonSection = selection.selectAll('.buttons')
275 .data((isSelected ? [_note] : []), function(d) { return d.status + d.id; });
276
277 // exit
278 buttonSection.exit()
279 .remove();
280
281 // enter
282 var buttonEnter = buttonSection.enter()
283 .append('div')
284 .attr('class', 'buttons');
285
286 if (_note.isNew()) {
287 buttonEnter
288 .append('button')
289 .attr('class', 'button cancel-button secondary-action')
290 .text(l10n.t('confirm.cancel'));
291
292 buttonEnter
293 .append('button')
294 .attr('class', 'button save-button action')
295 .text(l10n.t('note.save'));
296
297 } else {
298 buttonEnter
299 .append('button')
300 .attr('class', 'button status-button action');
301
302 buttonEnter
303 .append('button')
304 .attr('class', 'button comment-button action')
305 .text(l10n.t('note.comment'));
306 }
307
308
309 // update
310 buttonSection = buttonSection
311 .merge(buttonEnter);
312
313 buttonSection.select('.cancel-button') // select and propagate data
314 .on('click.cancel', clickCancel);
315
316 buttonSection.select('.save-button') // select and propagate data
317 .attr('disabled', isSaveDisabled)
318 .on('click.save', clickSave);
319
320 buttonSection.select('.status-button') // select and propagate data
321 .attr('disabled', (hasAuth ? null : true))
322 .text(function(d) {
323 var action = (d.status === 'open' ? 'close' : 'open');
324 var andComment = (d.newComment ? '_comment' : '');
325 return l10n.t('note.' + action + andComment);
326 })

Callers

nothing calls this directly

Calls 10

authenticatedMethod · 0.80
dataMethod · 0.80
isNewMethod · 0.80
selectedIDsMethod · 0.45
removeMethod · 0.45
exitMethod · 0.45
enterMethod · 0.45
tMethod · 0.45
mergeMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected