<commit_before>extends ../layout/base

include ../mixins/columns
include ../mixins/formFields

block css
	link(rel="stylesheet", href="/keystone/js/lib/fancybox/jquery.fancybox.css")

block js
	script(src='/keystone/js/lib/tinymce/tinymce.min.js')
	script(src='/keystone/js/lib/tinymce/jquery.tinymce.min.js')
	//- script(src='/keystone/js/lib/tinymcedev/tinymce.jquery.dev.js')
	
	script(src="/keystone/js/lib/fancybox/jquery.fancybox.pack.js")
	script(src="/keystone/js/common/ui-fixed-toolbar.js")
	script(src="/keystone/js/common/ui-cloudinaryimage.js")
	script(src="/keystone/js/common/ui-cloudinaryimages.js")
	script(src="/keystone/js/lib/html5sortable/jquery.sortable.js")
	script(src="/keystone/js/common/ui-s3file.js")
	script(src="/keystone/js/common/ui-wysiwyg.js")
	//- script(src="/keystone/js/common/ui-wysiwyg-dev.js")
	script(src='/keystone/js/views/item.js')
	//- script(src='/keystone/js/lib/wysihtml5/wysihtml5-0.4.0pre.min.js')
	//- script(src='/keystone/js/lib/wysihtml5/editor.js')
	script.
		Keystone.list = { path: "#{list.path}" };
		Keystone.item = { id: "#{item.id}" };

block intro
	.page-header.item-header: .row
		.col-sm-6: ul.breadcrumb
			if drilldown
				each d in drilldown.items
					if d.items
						li
							each di, i in d.items
								a(href=di.href, title=d.list.singular, data-toggle='tooltip', data-placement='top')= di.label
								if i < d.items.length - 1
									span , 
						if d.more
							li: span  ... 
					else
						li: a(href=d.href, title=d.list.singular, data-toggle='tooltip', data-placement='top') #{d.label}
			li
				a(href='/keystone/' + list.path, title='Back to ' + list.plural, data-toggle='tooltip', data-placement='top') #{list.label}
		.col-sm-6: .item-id
			if list.autokey && item.get(list.autokey.path)
				span(data-alt-text='id: ' + item.id) #{list.autokey.path}: #{item.get(list.autokey.path)}
			else
				| id: #{item.id}
			.btn-group.visible-md.visible-lg.pull-right(style='margin-left:20px')
				a.btn.btn-default.btn-xs(href='/keystone/#{list.path}?new') new #{list.singular.toLowerCase()}
				//- a.btn.btn-default.btn-xs(href='/keystone/#{list.path}/#{item.id}?duplicate') duplicate
			
block content
	form(method='post', enctype='multipart/form-data').item-details
		
		input(type='hidden', name='action', value='updateItem')
		
		- var nameField = list.nameField, nameIsEditable = list.nameIsEditable;
		
		.field.item-name: .col-sm-12
			if nameIsEditable
				input(type='text', name=list.nameField.path, value=item.get(list.nameField.path)).form-control.input-lg
			else if nameField
				h2.form-heading.name-value= list.nameField.format(item) || '(no name)'
			else
				h2.form-heading.name-value= item.get(list.namePath) || '(no name)'
		
		each el in list.uiElements
			if el.type == 'field'
				if (el.field.type != 'text' || el.field != nameField) && !el.field.hidden
					+formField(el.field, item)
			else if el.type == 'heading'
				h3.form-heading(data-field-depends-on=el.options.dependsOn)= el.heading
			else if el.type == 'indent'
				| <div class="form-indent">
			else if el.type == 'outdent'
				| </div>
		
		.toolbar.toolbar-fixed
			if !list.get('noedit')
				button(type='submit').btn.btn-default.btn-save Save
				a(href='/keystone/' + list.path + '/' + item.id, data-confirm='Are you sure you want to reset your changes?').btn.btn-link.btn-cancel reset changes
			if !list.get('nodelete')
				a(href='/keystone/' + list.path + '?delete=' + item.id, data-confirm='Are you sure you want to delete this ' + list.singular.toLowerCase() + '?').btn.btn-link.btn-cancel delete #{list.singular.toLowerCase()}
	
	if showRelationships
		h2.relationship-heading.form-heading Relationships
			each rel in relationships
				if rel.items.results.length
					h3.form-heading.relationship-heading: a(href='/keystone/' + rel.list.path)= rel.list.label
					- var firstColspan = 1
					table(cellpadding=0, cellspacing=0, class=rel.sortable ? 'sortable' : false, data-list-path=rel.list.path).table.table-striped.items-list.relationships-list
						if rel.sortable
							- firstColspan++;
							col(width=26)
						each col in rel.columns
							col(width=col.width)
						thead
							tr
								each col, i in rel.columns
									th(colspan=i == 0 && firstColspan > 1 ? firstColspan : false)= col.label
						tbody
							each item in rel.items.results
								tr(id=item.id)
									if rel.sortable
										td.control: a(href=js).control-sort
									each col, i in rel.columns
										td
											+column(rel.list, col, item)
<commit_msg>Relationships: support label and note options<commit_after>extends ../layout/base

include ../mixins/columns
include ../mixins/formFields

block css
	link(rel="stylesheet", href="/keystone/js/lib/fancybox/jquery.fancybox.css")

block js
	script(src='/keystone/js/lib/tinymce/tinymce.min.js')
	script(src='/keystone/js/lib/tinymce/jquery.tinymce.min.js')
	//- script(src='/keystone/js/lib/tinymcedev/tinymce.jquery.dev.js')
	
	script(src="/keystone/js/lib/fancybox/jquery.fancybox.pack.js")
	script(src="/keystone/js/common/ui-fixed-toolbar.js")
	script(src="/keystone/js/common/ui-cloudinaryimage.js")
	script(src="/keystone/js/common/ui-cloudinaryimages.js")
	script(src="/keystone/js/lib/html5sortable/jquery.sortable.js")
	script(src="/keystone/js/common/ui-s3file.js")
	script(src="/keystone/js/common/ui-wysiwyg.js")
	//- script(src="/keystone/js/common/ui-wysiwyg-dev.js")
	script(src='/keystone/js/views/item.js')
	//- script(src='/keystone/js/lib/wysihtml5/wysihtml5-0.4.0pre.min.js')
	//- script(src='/keystone/js/lib/wysihtml5/editor.js')
	script.
		Keystone.list = { path: "#{list.path}" };
		Keystone.item = { id: "#{item.id}" };

block intro
	.page-header.item-header: .row
		.col-sm-6: ul.breadcrumb
			if drilldown
				each d in drilldown.items
					if d.items
						li
							each di, i in d.items
								a(href=di.href, title=d.list.singular, data-toggle='tooltip', data-placement='top')= di.label
								if i < d.items.length - 1
									span , 
						if d.more
							li: span  ... 
					else
						li: a(href=d.href, title=d.list.singular, data-toggle='tooltip', data-placement='top') #{d.label}
			li
				a(href='/keystone/' + list.path, title='Back to ' + list.plural, data-toggle='tooltip', data-placement='top') #{list.label}
		.col-sm-6: .item-id
			if list.autokey && item.get(list.autokey.path)
				span(data-alt-text='id: ' + item.id) #{list.autokey.path}: #{item.get(list.autokey.path)}
			else
				| id: #{item.id}
			.btn-group.visible-md.visible-lg.pull-right(style='margin-left:20px')
				a.btn.btn-default.btn-xs(href='/keystone/#{list.path}?new') new #{list.singular.toLowerCase()}
				//- a.btn.btn-default.btn-xs(href='/keystone/#{list.path}/#{item.id}?duplicate') duplicate
			
block content
	form(method='post', enctype='multipart/form-data').item-details
		
		input(type='hidden', name='action', value='updateItem')
		
		- var nameField = list.nameField, nameIsEditable = list.nameIsEditable;
		
		.field.item-name: .col-sm-12
			if nameIsEditable
				input(type='text', name=list.nameField.path, value=item.get(list.nameField.path)).form-control.input-lg
			else if nameField
				h2.form-heading.name-value= list.nameField.format(item) || '(no name)'
			else
				h2.form-heading.name-value= item.get(list.namePath) || '(no name)'
		
		each el in list.uiElements
			if el.type == 'field'
				if (el.field.type != 'text' || el.field != nameField) && !el.field.hidden
					+formField(el.field, item)
			else if el.type == 'heading'
				h3.form-heading(data-field-depends-on=el.options.dependsOn)= el.heading
			else if el.type == 'indent'
				| <div class="form-indent">
			else if el.type == 'outdent'
				| </div>
		
		.toolbar.toolbar-fixed
			if !list.get('noedit')
				button(type='submit').btn.btn-default.btn-save Save
				a(href='/keystone/' + list.path + '/' + item.id, data-confirm='Are you sure you want to reset your changes?').btn.btn-link.btn-cancel reset changes
			if !list.get('nodelete')
				a(href='/keystone/' + list.path + '?delete=' + item.id, data-confirm='Are you sure you want to delete this ' + list.singular.toLowerCase() + '?').btn.btn-link.btn-cancel delete #{list.singular.toLowerCase()}
	
	if showRelationships
		h2.relationship-heading.form-heading Relationships
			each rel in relationships
				if rel.items.results.length
					h3.form-heading.relationship-heading: a(href='/keystone/' + rel.list.path)= (rel.label) ? rel.label : rel.list.label
					if rel.note
						.field-note= rel.note
					- var firstColspan = 1
					table(cellpadding=0, cellspacing=0, class=rel.sortable ? 'sortable' : false, data-list-path=rel.list.path).table.table-striped.items-list.relationships-list
						if rel.sortable
							- firstColspan++;
							col(width=26)
						each col in rel.columns
							col(width=col.width)
						thead
							tr
								each col, i in rel.columns
									th(colspan=i == 0 && firstColspan > 1 ? firstColspan : false)= col.label
						tbody
							each item in rel.items.results
								tr(id=item.id)
									if rel.sortable
										td.control: a(href=js).control-sort
									each col, i in rel.columns
										td
											+column(rel.list, col, item)

{'fraction_non_alphanumeric': 0.17324203890881426, 'fraction_numerical': 0.0058689272905119005, 'mean_word_length': 3.192255125284738, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '485230', 'n_tokens_mistral': 4028, 'n_tokens_neox': 3323, 'n_words': 543}