Exemplo n.º 1
0
        public EditableDocumentModel()
        {
            ModelUrl = "/edit";
            ApplicationModel.Current.Server.Value.RawUrl = null;

            dataSection = new DocumentSection {
                Name = "Data", Document = new EditorDocument {
                    Language = JsonLanguage, TabSize = 2
                }
            };
            metaDataSection = new DocumentSection {
                Name = "Metadata", Document = new EditorDocument {
                    Language = JsonLanguage, TabSize = 2
                }
            };
            DocumentSections = new List <DocumentSection> {
                dataSection, metaDataSection
            };
            EnableExpiration          = new Observable <bool>();
            ExpireAt                  = new Observable <DateTime?>();
            ExpireAt.PropertyChanged += (sender, args) => TimeChanged = true;
            CurrentSection            = dataSection;

            References = new BindableCollection <LinkModel>(model => model.Title);
            Related    = new BindableCollection <LinkModel>(model => model.Title);
            Recent     = new BindableCollection <LinkModel>(model => model.Title);

            foreach (var recentDocument in ApplicationModel.Current.Server.Value.SelectedDatabase.Value.RecentDocuments)
            {
                Recent.Add(new LinkModel(recentDocument));
            }

            DocumentErrors = new ObservableCollection <DocumentError>();

            SearchEnabled = false;

            document = new Observable <JsonDocument>();
            document.PropertyChanged            += (sender, args) => UpdateFromDocument();
            documentIdManager                    = JsonDataDocument.Properties.GetOrCreateSingleton(() => new DocumentReferencedIdManager());
            documentIdManager.CurrentIdsChanged += HandleCurrentIdsChanged;

            InitializeDocument();

            ParentPathSegments = new ObservableCollection <PathSegment>
            {
                new PathSegment {
                    Name = "Documents", Url = "/documents"
                }
            };

            currentDatabase = Database.Value.Name;

            dataSection.Document.ObserveTextChanged()
            .Merge(metaDataSection.Document.ObserveTextChanged())
            .Do(_ => HasUnsavedChanges = true)
            .Throttle(TimeSpan.FromSeconds(1))
            .ObserveOnDispatcher()
            .Subscribe(e => HandleDocumentChanged());
        }
Exemplo n.º 2
0
        public EditableDocumentModel()
        {
            ModelUrl = "/edit";

            dataSection = new DocumentSection()
            {
                Name = "Data", Document = new EditorDocument()
                {
                    Language = JsonLanguage, TabSize = 2
                }
            };
            metaDataSection = new DocumentSection()
            {
                Name = "Metadata", Document = new EditorDocument()
                {
                    Language = JsonLanguage, TabSize = 2
                }
            };
            DocumentSections = new List <DocumentSection>()
            {
                dataSection, metaDataSection
            };
            CurrentSection = dataSection;

            References     = new BindableCollection <LinkModel>(model => model.Title);
            Related        = new BindableCollection <LinkModel>(model => model.Title);
            DocumentErrors = new ObservableCollection <DocumentError>();

            SearchEnabled = false;

            document = new Observable <JsonDocument>();
            document.PropertyChanged += (sender, args) => UpdateFromDocument();
            documentIdManager         = JsonDataDocument.Properties.GetOrCreateSingleton(() => new DocumentReferencedIdManager());

            InitialiseDocument();

            ParentPathSegments = new ObservableCollection <PathSegment>()
            {
                new PathSegment()
                {
                    Name = "Documents", Url = "/documents"
                }
            };

            currentDatabase = Database.Value.Name;

            dataSection.Document.ObserveTextChanged()
            .Merge(metaDataSection.Document.ObserveTextChanged())
            .Do(_ => HasUnsavedChanges = true)
            .Throttle(TimeSpan.FromSeconds(1))
            .ObserveOnDispatcher()
            .Subscribe(e => HandleDocumentChanged());
        }
Exemplo n.º 3
0
        private void AddErrors(DocumentSection section)
        {
            var parseData = section.Document.ParseData as ILLParseData;

            if (parseData == null)
            {
                return;
            }

            foreach (var parseError in parseData.Errors)
            {
                DocumentErrors.Add(new DocumentError {
                    Section = section, ParseError = parseError
                });
            }
        }
Exemplo n.º 4
0
		public EditableDocumentModel()
		{
			ModelUrl = "/edit";
			ApplicationModel.Current.Server.Value.RawUrl = null;

			dataSection = new DocumentSection{ Name = "Data", Document = new EditorDocument { Language = JsonLanguage, TabSize = 2 } };
			metaDataSection = new DocumentSection{ Name = "Metadata", Document = new EditorDocument { Language = JsonLanguage, TabSize = 2 } };
			DocumentSections = new List<DocumentSection> { dataSection, metaDataSection };
			EnableExpiration = new Observable<bool>();
			ExpireAt = new Observable<DateTime>();
			ExpireAt.PropertyChanged += (sender, args) => TimeChanged = true;
			CurrentSection = dataSection;

			References = new BindableCollection<LinkModel>(model => model.Title);
			Related = new BindableCollection<LinkModel>(model => model.Title);
			Recent = new BindableCollection<LinkModel>(model => model.Title);

			foreach (var recentDocument in ApplicationModel.Current.Server.Value.SelectedDatabase.Value.RecentDocuments)
			{
				Recent.Add(new LinkModel(recentDocument));
			}

			DocumentErrors = new ObservableCollection<DocumentError>();

			SearchEnabled = false;

			document = new Observable<JsonDocument>();
			document.PropertyChanged += (sender, args) => UpdateFromDocument();
			documentIdManager = JsonDataDocument.Properties.GetOrCreateSingleton(() => new DocumentReferencedIdManager());

			InitializeDocument();

			ParentPathSegments = new ObservableCollection<PathSegment>
			                     {
				                     new PathSegment { Name = "Documents", Url = "/documents" }
			                     };

			currentDatabase = Database.Value.Name;

			dataSection.Document.ObserveTextChanged()
			           .Merge(metaDataSection.Document.ObserveTextChanged())
			           .Do(_ => HasUnsavedChanges = true)
			           .Throttle(TimeSpan.FromSeconds(1))
			           .ObserveOnDispatcher()
			           .Subscribe(e => HandleDocumentChanged());
		}
Exemplo n.º 5
0
		private void AddErrors(DocumentSection section)
		{
			var parseData = section.Document.ParseData as ILLParseData;
			if (parseData == null)
			{
				return;
			}

			foreach (var parseError in parseData.Errors)
			{
				DocumentErrors.Add(new DocumentError { Section = section, ParseError = parseError });
			}
		}
Exemplo n.º 6
0
		public EditableDocumentModel()
		{
			ModelUrl = "/edit";

			dataSection = new DocumentSection() { Name = "Data", Document = new EditorDocument() { Language = JsonLanguage, TabSize = 2 } };
			metaDataSection = new DocumentSection() { Name = "Metadata", Document = new EditorDocument() { Language = JsonLanguage, TabSize = 2 } };
			DocumentSections = new List<DocumentSection>() { dataSection, metaDataSection };
			CurrentSection = dataSection;

			References = new BindableCollection<LinkModel>(model => model.Title);
			Related = new BindableCollection<LinkModel>(model => model.Title);
			DocumentErrors = new ObservableCollection<DocumentError>();

			SearchEnabled = false;

			document = new Observable<JsonDocument>();
			document.PropertyChanged += (sender, args) => UpdateFromDocument();
			documentIdManager = JsonDataDocument.Properties.GetOrCreateSingleton(() => new DocumentReferencedIdManager());

			InitialiseDocument();

			ParentPathSegments = new ObservableCollection<PathSegment>()
									 {
										 new PathSegment() { Name="Documents", Url = "/documents"}
									 };

			currentDatabase = Database.Value.Name;

			dataSection.Document.ObserveTextChanged()
				.Merge(metaDataSection.Document.ObserveTextChanged())
				.Do(_ => HasUnsavedChanges = true)
				.Throttle(TimeSpan.FromSeconds(1))
				.ObserveOnDispatcher()
				.Subscribe(e => HandleDocumentChanged());
		}
Exemplo n.º 7
0
		public EditableDocumentModel()
		{
			ModelUrl = "/edit";
			ApplicationModel.Current.Server.Value.RawUrl = null;

			dataSection = new DocumentSection{ Name = "Data", Document = new EditorDocument { Language = JsonLanguage, TabSize = 2 } };
			metaDataSection = new DocumentSection{ Name = "Metadata", Document = new EditorDocument { Language = JsonLanguage, TabSize = 2 } };
			DocumentSections = new List<DocumentSection> { dataSection, metaDataSection };
			EnableExpiration = new Observable<bool>();
			ExpireAt = new Observable<DateTime>();
			ExpireAt.PropertyChanged += (sender, args) => TimeChanged = true;
			CurrentSection = dataSection;
			
			var databaseName = ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Name;
			ApplicationModel.Current.Server.Value.DocumentStore
			                .AsyncDatabaseCommands
							.ForSystemDatabase()
			                .CreateRequest("/admin/databases/" + databaseName, "GET")
			                .ReadResponseJsonAsync()
			                .ContinueOnSuccessInTheUIThread(doc =>
			                {
				                if (doc == null)
					                return;

				                var databaseDocument = ApplicationModel.Current.Server.Value.DocumentStore.Conventions
				                                                       .CreateSerializer()
				                                                       .Deserialize<DatabaseDocument>(new RavenJTokenReader(doc));

				                string activeBundles;
				                databaseDocument.Settings.TryGetValue("Raven/ActiveBundles", out activeBundles);

				                if (activeBundles == null) 
									return;
				                if (activeBundles.Contains("Expiration"))
				                {
					                hasExpiration = true;
									OnPropertyChanged(() => HasExpiration);
				                }
			                });

			References = new BindableCollection<LinkModel>(model => model.Title);
			Related = new BindableCollection<LinkModel>(model => model.Title);
			Recent = new BindableCollection<LinkModel>(model => model.Title);

			foreach (var recentDocument in ApplicationModel.Current.Server.Value.SelectedDatabase.Value.RecentDocuments)
			{
				Recent.Add(new LinkModel(recentDocument));
			}

			DocumentErrors = new ObservableCollection<DocumentError>();

			SearchEnabled = false;

			document = new Observable<JsonDocument>();
			document.PropertyChanged += (sender, args) => UpdateFromDocument();
			documentIdManager = JsonDataDocument.Properties.GetOrCreateSingleton(() => new DocumentReferencedIdManager());

			InitializeDocument();

			ParentPathSegments = new ObservableCollection<PathSegment>
			                     {
				                     new PathSegment { Name = "Documents", Url = "/documents" }
			                     };

			currentDatabase = Database.Value.Name;

			dataSection.Document.ObserveTextChanged()
			           .Merge(metaDataSection.Document.ObserveTextChanged())
			           .Do(_ => HasUnsavedChanges = true)
			           .Throttle(TimeSpan.FromSeconds(1))
			           .ObserveOnDispatcher()
			           .Subscribe(e => HandleDocumentChanged());
		}