summaryrefslogblamecommitdiffstats
path: root/web/js/labitrack.d/41-create.js
blob: 4a1f37fb19e95bf5a2c43400d41fb5fe62ec3512 (plain) (tree)
1
2
3
4
5
6
7
8
9
            
                                             


                                                           



                                                      

                                                                             



                                                                        




















                                                                         
(function(){
	function on_submit(label, o, print) {
		o.save(undef, {
			success: function(){
				label.set_data(o.toJSON());
				if (print) {
					label.print();
				}
				var id = o.get('id');

				console.log('Saved with id: ' + o.get('id'));
				λ.alert('newlabel', {id: o.get('id')});

				o.set('id', undefined);
				label.trigger_refresh();
			}
		});
	}

	var view = λ.routableview.extend({
		render: function () {
			λ.setcontent('create', {
				save_text: 'Save and queue for printing',
				data: {},
				tags: λ.tags
			});
			var o = new λ.o();
			λ.labelform({
				model: o,
				submit: on_submit
			});
		}
	});

	view.route('', 'create');
}());