public ActionResult GetDefinitionLevel(DefinitionPathInfo defInfo) { var content = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var objects = DefinitionTreeNode.GetObjectsFromPath(content, defInfo.Path, _fieldService, _definitionEditorService, _contentService); return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(objects) }); }
public ActionResult Edit(DefinitionPathInfo defInfo) { var rootContent = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var objectToEdit = _definitionEditorService.GetObjectFromPath(rootContent, defInfo.Path, out var notFoundInDef); if (objectToEdit is Field edit) { return new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(new DefinitionFieldInfo(edit) { InDefinition = !notFoundInDef, Path = defInfo.Path, Xml = defInfo.Xml } ) } } ; var isFromDictionaries = false; if (!Equals(rootContent, objectToEdit)) { isFromDictionaries = _definitionEditorService.GetParentObjectFromPath(rootContent, defInfo.Path) is Dictionaries; } var contentToEdit = (Content)objectToEdit; return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(new DefinitionContentInfo { ContentName = contentToEdit.ContentName, IsReadOnly = contentToEdit.IsReadOnly, PublishingMode = contentToEdit.PublishingMode, ContentId = contentToEdit.ContentId, LoadAllPlainFields = contentToEdit.LoadAllPlainFields, CacheEnabled = contentToEdit.CachePeriod.HasValue, CachePeriod = contentToEdit.CachePeriod ?? new TimeSpan(1, 45, 0), Path = defInfo.Path, Xml = defInfo.Xml, InDefinition = !notFoundInDef, IsFromDictionaries = isFromDictionaries, }) }); }
public ActionResult GetSingleNode(DefinitionPathInfo defInfo) { var content = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var objFromDef = _definitionEditorService.GetObjectFromPath(content, defInfo.Path, out var notFoundInDef); if (objFromDef == null) { return(Json(new { MissingFieldToDeleteId = defInfo.Path })); } DefinitionTreeNode resultObj = null; switch (objFromDef) { case Content def: { var isFromDictionaries = _definitionEditorService.GetParentObjectFromPath(content, defInfo.Path) is Dictionaries; resultObj = new DefinitionTreeNode(def, null, defInfo.Path, isFromDictionaries, notFoundInDef, _contentService); break; } case Field field: { var existsInQp = true; if (!(field is BaseVirtualField)) { existsInQp = _fieldService.Read(field.FieldId) != null; } resultObj = new DefinitionTreeNode(field, null, defInfo.Path, !existsInQp, notFoundInDef); break; } } return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(resultObj) }); }