Skip to content

Commit

Permalink
#161: Models: Add some debugLog() calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taitava committed Apr 14, 2022
1 parent a8038fd commit 0f3f617
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/models/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Contact the author (Jarkko Linnanvirta): https://github.com/Taitava/
*/

import {debugLog} from "../Debug";
import {
Model
} from "../imports";
Expand All @@ -40,6 +41,8 @@ export abstract class Instance {
public readonly configuration: InstanceConfiguration,
parent_instance_or_configuration: Instance | InstanceConfiguration,
) {
debugLog(this.constructor.name + ": Creating a new instance.");

// Determine parent type
if (parent_instance_or_configuration instanceof Instance) {
// It's an instance object
Expand Down
4 changes: 4 additions & 0 deletions src/models/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import SC_Plugin from "../main";
import {Setting} from "obsidian";
import {debugLog} from "../Debug";
import {
ConfirmationModal,
Instance,
Expand Down Expand Up @@ -49,6 +50,8 @@ export abstract class Model {
public abstract newInstance(parent_instance_or_configuration: Instance | InstanceConfiguration): Instance;

public createSettingFields(instance: Instance, parent_element: HTMLElement, with_deletion = true) {
debugLog(this.constructor.name + ": Creating setting fields.");

// Create a container
const setting_fields_container = parent_element.createDiv(); // Create a nested container that can be easily deleted if the instance is deleted.

Expand Down Expand Up @@ -102,6 +105,7 @@ export abstract class Model {
* Can be made public if needed.
*/
public deleteInstance(instance: Instance) {
debugLog(this.constructor.name + ": Deleting an instance.");
this._deleteInstance(instance);
const relation = this.defineParentConfigurationRelation(instance);
switch (relation.type) {
Expand Down
2 changes: 2 additions & 0 deletions src/models/createNewModelInstanceButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import SC_Plugin from "../main";
import {Setting} from "obsidian";
import {debugLog} from "../Debug";
import {
getModel,
Instance,
Expand All @@ -39,6 +40,7 @@ export function createNewModelInstanceButton<
parent_instance_or_configuration: InstanceClass["parent_configuration"] | InstanceClass["parent_instance"]
): Promise<{instance: InstanceClass, main_setting: Setting}> {

debugLog("Creating a button for creating a new instance for model " + model_class_name + ".");
return new Promise((resolve_promise) => {
const model = getModel<ModelClass>(model_class_name);
new Setting(button_container_element)
Expand Down
3 changes: 3 additions & 0 deletions src/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import SC_Plugin from "../main";
import {debugLog} from "../Debug";
import {
CustomVariableModel,
introduceModelClass,
Expand All @@ -26,6 +27,8 @@ import {
} from "../imports";

export function introduceModels(plugin: SC_Plugin) {
debugLog("Introducing models.")

// Keep in alphabetical order, if possible.
introduceModelClass(new CustomVariableModel(plugin));
introduceModelClass(new PromptFieldModel(plugin));
Expand Down

0 comments on commit 0f3f617

Please sign in to comment.