Adding the "Notes" field to a detail + working with images

Question 

I have a problem with uploading images after adding the standard functionality of "Notes". Notes are added to a detail. A separate object is created for the detail. Notes are added to the detail page schema as follows: the text is saved, images are not even uploaded. The insertImagesToNotes  method is not executed. Why?

Answer

The base detail, which all the rest of details are inherited from, does not have the necessary attributes, methods and mixins. Unlike pages that are inherited from BaseModulePageV2.

You can fix this by viewing at what has been implemented in BaseModulePageV2 and reproducing it in your detail. Create the detail object based on Base object with notes (Base) and create a detail based on this object via the detail wizard.

Add the following in the configurator page schema:

1. Dependency of requirejs from NotesUtilities ;

2. The following attribute:

attributes: {
    "NotesImagesCollection": {dataValueType:Terrasoft.DataValueType.COLLECTION}
},

3. The mixin:

mixins: {
    NotesUtilities: "Terrasoft.NotesUtilities"
},

4. The methods:

methods: {
        onNotesImagesUploadComplete: function() {
                this.hideBodyMask();
                this.updateFileDetail();
        },
        onNotesImagesUpload: function() {
                this.showBodyMask();
        },
        init: function(callback, scope) {
                this.callParent(arguments);
               this.mixins.NotesUtilities.initNotesImagesCollection.call(this);
        }
},

5. The notes field in the diff property:

{
        "operation": "insert",
        "parentName": "Header",
        "propertyName": "items",
        "name": "Notes",
        "bindTo": "Notes",
        "values": {
                contentType: Terrasoft.ContentType.RICH_TEXT,
                "layout" : {column: 0, row: 1, colSpan: 24},
                "controlConfig": {
                        "imageLoaded": {
                                "bindTo": "insertImagesToNotes"
                        },
                        "images": {
                                "bindTo": "NotesImagesCollection"
                        }
                }
        },
        "index": 1
}

The test schema code for the detail edit page:

define("UsrUsrMyDetail1Page", ["NotesUtilities"], function() {
	return {
		entitySchemaName: "UsrMyDetail",
		details: {},
		attributes: {
			"NotesImagesCollection": {dataValueType: Terrasoft.DataValueType.COLLECTION}
		},
		mixins: {
			NotesUtilities: "Terrasoft.NotesUtilities"
		},
		diff: [{
			"operation": "insert",
			"name": "UsrIntbcb7788a-2890-4358-bff3-102e82ea7889",
			"values": {
				"layout": {
					"colSpan": 12,
					"rowSpan": 1,
					"column": 0,
					"row": 0,
					"layoutName": "Header"
				},
				"labelConfig": {},
				"enabled": true,
				"bindTo": "UsrInt"
			},
			"parentName": "Header",
			"propertyName": "items",
			"index": 0
		},
		{
			"operation": "insert",
			"parentName": "Header",
			"propertyName": "items",
			"name": "Notes",
			"bindTo": "Notes",
			"values": {
				contentType: Terrasoft.ContentType.RICH_TEXT,
				"layout" : {column: 0, row: 1, colSpan: 24},
				"controlConfig": {
					"imageLoaded": {
						"bindTo": "insertImagesToNotes"
					},
					"images": {
						"bindTo": "NotesImagesCollection"
					}
				}
			},
			"index": 1
		}],
		methods: {
			onNotesImagesUploadComplete: function() {
				this.hideBodyMask();
				this.updateFileDetail();
			},
			onNotesImagesUpload: function() {
				this.showBodyMask();
			},
			init: function(callback, scope) {
				this.callParent(arguments);
				this.mixins.NotesUtilities.initNotesImagesCollection.call(this);
			}
		},
		rules: {}
	};
});

 

Like 0

Like

Share

0 comments
Show all comments