summaryrefslogtreecommitdiffstats
path: root/web/js/labitrack.d/41-create.js
blob: 4a1f37fb19e95bf5a2c43400d41fb5fe62ec3512 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(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');
}());