Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig Cronin 304 posts 503 karma points
    Aug 13, 2018 @ 13:55
    Craig Cronin
    0

    AngularJS basics.....

    I'm currently looking at building a custom section for a website and I'm working on the editor page.

    I have a date picker control which I have found in the documentation https://our.umbraco.com/apidocs/ui/#/api/umbraco.directives.directive:umbDateTimePicker

    I can't seem to get the date to populate/bind though. I was expecting to have either ng-model or model="vm.workshop.date"

    Any help would be appreciated.

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 14, 2018 @ 07:41
    Dave Woestenborghs
    0

    Hi Craig,

    I think you need to set the date as part of the options passed to picker. In the docs of the directive there is a link to documentation of the date picker control.

    In this part http://eonasdan.github.io/bootstrap-datetimepicker/#enableddisabled-dates you can see they pass the defaultDate as an option.

    can you try that ?

    Dave

  • Craig Cronin 304 posts 503 karma points
    Aug 14, 2018 @ 07:55
    Craig Cronin
    0

    Hi Dave,

    I've tried both of these below, but I can't get it to show the date. I have text fields on the form which work like normal :(

        vm.date = vm.workshop.date;
    
        vm.config = {
            pickDate: true,
            pickTime: false,
            useSeconds: false,
            defaultDate: vm.workshop.date,
            format: "DD/MM/YYYY",
            icons: {
                time: "icon-time",
                date: "icon-calendar",
                up: "icon-chevron-up",
                down: "icon-chevron-down"
            }
        };
    
  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 14, 2018 @ 08:03
    Dave Woestenborghs
    0

    Hi Craig,

    What if you just put in a string like '01/01/2018' for default date.

    Does it get set ?

    Dave

  • Craig Cronin 304 posts 503 karma points
    Aug 14, 2018 @ 08:18
    Craig Cronin
    0

    Hmmmm, yes that works?

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 14, 2018 @ 08:25
    Dave Woestenborghs
    1

    So my guess than is that vm.workshop.date is not a valid date.

    Dave

  • Craig Cronin 304 posts 503 karma points
    Aug 14, 2018 @ 08:26
    Craig Cronin
    0

    just sent it to the console and its undefined. Thanks dave, just trying to get me head around how angularjs is working with umb fields :(

  • Craig Cronin 304 posts 503 karma points
    Aug 15, 2018 @ 09:55
    Craig Cronin
    0

    This is freaking me out.

    The date now appears when I initially go into my custom section, but when I select tree items the date field goes blank even though I know the model has the information.

        vm.config = {
            pickDate: true,
            pickTime: false,
            useSeconds: false,
            format: "DD/MM/YYYY",
            icons: {
                time: "icon-time",
                date: "icon-calendar",
                up: "icon-chevron-up",
                down: "icon-chevron-down"
            }
        };
    
        //save
        vm.save = function () {
            vm.buttonState = "busy";
            workshopResource.save(vm.workshop).then(function (response) {
                vm.buttonState = "success";
                vm.workshop = response.data;
                notificationsService.success("Workshop saved!");
            });
        };
    
        //initialize
        if (!$routeParams.create) {
            workshopResource.getById($routeParams.id).then(function (response) {
                vm.workshop = response.data;
                vm.config.defaultDate = moment(vm.workshop.date);
                console.log(vm.workshop.date);
            });
        }
    
        vm.datePickerChange = datePickerChange;
    
        function datePickerChange(event) {
            if (event.date && event.date.isValid()) {
                vm.workshop.date = event.date;
    
  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 15, 2018 @ 09:59
    Dave Woestenborghs
    100

    Hi Craig,

    Maybe don't show the date picker untill the data is loaded. Maybe it get's initialized before your api request that get's the data has been completed.

    probably adding a ng-if to the data picker directive with a boolean indicating data has loaded could solve this.

    Dave

  • Craig Cronin 304 posts 503 karma points
    Aug 15, 2018 @ 10:17
    Craig Cronin
    0

    Thanks Dave, I'll give it a try now :)

  • Craig Cronin 304 posts 503 karma points
    Aug 15, 2018 @ 10:49
    Craig Cronin
    0

    Thanks for you help Dave, I don't quite understand why but

    this works, getting my training videos out later :)

  • Craig Cronin 304 posts 503 karma points
    Aug 16, 2018 @ 10:27
    Craig Cronin
    0

    Hi Dave, sorry to bother you but I can see you have built custom sections and have a good idea how things work.

    I have one small minor issue. I have checked all the documentation but can't seem to find the answer.

    All is working but I have a 2 layer tree view

    Date Folder -> Date -> Date Date Folder -> Date -> Date

    How do I only allow the click event when somebody clicks Date. At the moment it runs when I click Date Folder and date?enter image description here

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 16, 2018 @ 10:39
    Dave Woestenborghs
    0

    Hi Craig,

    Am i understanding correctly that you don't want the first level in the tree to be clicked ?

    Dave

  • Craig Cronin 304 posts 503 karma points
    Aug 16, 2018 @ 10:40
    Craig Cronin
    0

    Yes.

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 16, 2018 @ 11:02
    Dave Woestenborghs
    0

    Hi Craig,

    Create some css like this ;

    .umb-tree li div.no-click .root-link, .umb-tree li div.no-click .umb-tree-icon, .umb-tree li div.no-click .umb-tree-item__label {
        pointer-events:none;
    }
    

    And then in your tree controller add this to the nodes that you don't want to be clicked :

    treeNode.CssClasses.Add('no-click');
    

    Haven't tested it but I think this should do the trick.

    Dave

  • Craig Cronin 304 posts 503 karma points
    Aug 16, 2018 @ 12:39
    Craig Cronin
    0

    Worked a treat....you're a life saver Dave thank you. I've started my angularjs training now :)

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Aug 16, 2018 @ 12:42
    Dave Woestenborghs
    0

    Nice...something I will be using myself as well now.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft