3 * Copyright 2016-2017 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 import getEventPath
from '../../libraries/getEventPath'
20 import DeletionManager
from '../../libraries/DeletionManager'
22 function startEditing() {
23 DeletionManager
.removeEventListeners();
26 function endEditing() {
27 DeletionManager
.addEventListeners();
30 function onFocusPropertyFormInputElement(event
) {
32 console
.debug('property focus ', event
.target
.id
);
33 event
.preventDefault();
36 function removeIsFocusedClass(event
) {
37 event
.target
.removeEventListener('blur', removeIsFocusedClass
);
38 Array
.from(document
.querySelectorAll('.-is-focused')).forEach(d
=> d
.classList
.remove('-is-focused'));
41 removeIsFocusedClass(event
);
43 const propertyWrapper
= getEventPath(event
).reduce((parent
, element
) => {
47 if (!element
.classList
) {
50 if (element
.classList
.contains('property')) {
55 if (propertyWrapper
) {
56 propertyWrapper
.classList
.add('-is-focused');
57 event
.target
.addEventListener('blur', removeIsFocusedClass
);
61 function getTitle(model
= {}) {
62 if (typeof model
['short-name'] === 'string' && model
['short-name']) {
63 return model
['short-name'];
65 if (typeof model
.name
=== 'string' && model
.name
) {
68 if (model
.uiState
&& typeof model
.uiState
.displayName
=== 'string' && model
.uiState
.displayName
) {
69 return model
.uiState
.displayName
71 if (typeof model
.id
=== 'string') {
79 onFocusPropertyFormInputElement
,