Пример #1
0
 private void OnVersioning(VersionContentContext context, EntityMetadataPart existing, EntityMetadataPart building) {
     building.Record.FieldMetadataRecords = new List<FieldMetadataRecord>();
     foreach (var record in existing.Record.FieldMetadataRecords) {
         var newRecord = new FieldMetadataRecord();
         _fieldMetadataRepository.Copy(record, newRecord);
         newRecord.OriginalId = record.Id;
         newRecord.EntityMetadataRecord = building.Record;
         _fieldMetadataRepository.Create(newRecord);
         building.Record.FieldMetadataRecords.Add(newRecord);
     }
 }
Пример #2
0
 public void UpdateField(FieldMetadataRecord record, string displayName, IUpdateModel updateModel) {
     var settingsDictionary = ParseSetting(record.Settings);
     settingsDictionary["DisplayName"] = displayName;
     _contentDefinitionEditorEvents.UpdateFieldSettings(record.ContentFieldDefinitionRecord.Name, record.Name, settingsDictionary, updateModel);
     record.Settings = CompileSetting(settingsDictionary);
 }
Пример #3
0
        private void AddField(string entityName, FieldMetadataRecord field, bool needEvent = true) {
            var settings = _settingsFormatter.Map(Parse(field.Settings));

            // add field to part
            _contentDefinitionManager.AlterPartDefinition(entityName, builder => {
                string fieldTypeName = field.ContentFieldDefinitionRecord.Name;
                builder.WithField(field.Name, fieldBuilder =>
                    fieldBuilder.OfType(fieldTypeName).WithSetting("Storage", "Part"));
            });

            // update field settings
            _contentDefinitionManager.AlterPartDefinition(entityName, builder =>
                builder.WithField(field.Name, fieldBuilder =>
                    _contentDefinitionEditorEvents.UpdateFieldSettings(fieldBuilder, settings))
                );

            field.Settings = _settingsFormatter.Map(settings).ToString();

            if (needEvent) {
                _fieldEvents.OnCreated(entityName, field.Name, bool.Parse(settings["AddInLayout"]));
            }
        }
Пример #4
0
 public void CreateField(EntityMetadataPart entity, AddFieldViewModel viewModel, IUpdateModel updateModel) {
     var settingsDictionary = new SettingsDictionary();
     settingsDictionary["DisplayName"] = viewModel.DisplayName;
     settingsDictionary["AddInLayout"] = viewModel.AddInLayout.ToString();
     settingsDictionary["EntityName"] = entity.Name;
     var field = new FieldMetadataRecord {
         ContentFieldDefinitionRecord = FetchFieldDefinition(viewModel.FieldTypeName),
         Name = viewModel.Name
     };
     entity.FieldMetadataRecords.Add(field);
     _contentDefinitionEditorEvents.UpdateFieldSettings(viewModel.FieldTypeName, viewModel.Name, settingsDictionary, updateModel);
     field.Settings = CompileSetting(settingsDictionary);
     field.EntityMetadataRecord = entity.Record;
 }